swarm/network: Rename minproxbinsize, add as member of simulation (#18408)
* swarm/network: Rename minproxbinsize, add as member of simulation * swarm/network: Deactivate WaitTillHealthy, unreliable pending suggestpeer
This commit is contained in:
		@@ -55,7 +55,7 @@ var Pof = pot.DefaultPof(256)
 | 
				
			|||||||
type KadParams struct {
 | 
					type KadParams struct {
 | 
				
			||||||
	// adjustable parameters
 | 
						// adjustable parameters
 | 
				
			||||||
	MaxProxDisplay    int   // number of rows the table shows
 | 
						MaxProxDisplay    int   // number of rows the table shows
 | 
				
			||||||
	MinProxBinSize int   // nearest neighbour core minimum cardinality
 | 
						NeighbourhoodSize int   // nearest neighbour core minimum cardinality
 | 
				
			||||||
	MinBinSize        int   // minimum number of peers in a row
 | 
						MinBinSize        int   // minimum number of peers in a row
 | 
				
			||||||
	MaxBinSize        int   // maximum number of peers in a row before pruning
 | 
						MaxBinSize        int   // maximum number of peers in a row before pruning
 | 
				
			||||||
	RetryInterval     int64 // initial interval before a peer is first redialed
 | 
						RetryInterval     int64 // initial interval before a peer is first redialed
 | 
				
			||||||
@@ -69,7 +69,7 @@ type KadParams struct {
 | 
				
			|||||||
func NewKadParams() *KadParams {
 | 
					func NewKadParams() *KadParams {
 | 
				
			||||||
	return &KadParams{
 | 
						return &KadParams{
 | 
				
			||||||
		MaxProxDisplay:    16,
 | 
							MaxProxDisplay:    16,
 | 
				
			||||||
		MinProxBinSize: 2,
 | 
							NeighbourhoodSize: 2,
 | 
				
			||||||
		MinBinSize:        2,
 | 
							MinBinSize:        2,
 | 
				
			||||||
		MaxBinSize:        4,
 | 
							MaxBinSize:        4,
 | 
				
			||||||
		RetryInterval:     4200000000, // 4.2 sec
 | 
							RetryInterval:     4200000000, // 4.2 sec
 | 
				
			||||||
@@ -175,7 +175,7 @@ func (k *Kademlia) SuggestPeer() (a *BzzAddr, o int, want bool) {
 | 
				
			|||||||
	k.lock.Lock()
 | 
						k.lock.Lock()
 | 
				
			||||||
	defer k.lock.Unlock()
 | 
						defer k.lock.Unlock()
 | 
				
			||||||
	minsize := k.MinBinSize
 | 
						minsize := k.MinBinSize
 | 
				
			||||||
	depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						depth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
	// if there is a callable neighbour within the current proxBin, connect
 | 
						// if there is a callable neighbour within the current proxBin, connect
 | 
				
			||||||
	// this makes sure nearest neighbour set is fully connected
 | 
						// this makes sure nearest neighbour set is fully connected
 | 
				
			||||||
	var ppo int
 | 
						var ppo int
 | 
				
			||||||
@@ -306,7 +306,7 @@ func (k *Kademlia) sendNeighbourhoodDepthChange() {
 | 
				
			|||||||
	// It provides signaling of neighbourhood depth change.
 | 
						// It provides signaling of neighbourhood depth change.
 | 
				
			||||||
	// This part of the code is sending new neighbourhood depth to nDepthC if that condition is met.
 | 
						// This part of the code is sending new neighbourhood depth to nDepthC if that condition is met.
 | 
				
			||||||
	if k.nDepthC != nil {
 | 
						if k.nDepthC != nil {
 | 
				
			||||||
		nDepth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
							nDepth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
		if nDepth != k.nDepth {
 | 
							if nDepth != k.nDepth {
 | 
				
			||||||
			k.nDepth = nDepth
 | 
								k.nDepth = nDepth
 | 
				
			||||||
			k.nDepthC <- nDepth
 | 
								k.nDepthC <- nDepth
 | 
				
			||||||
@@ -366,7 +366,7 @@ func (k *Kademlia) EachBin(base []byte, pof pot.Pof, o int, eachBinFunc func(con
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	var startPo int
 | 
						var startPo int
 | 
				
			||||||
	var endPo int
 | 
						var endPo int
 | 
				
			||||||
	kadDepth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						kadDepth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	k.conns.EachBin(base, Pof, o, func(po, size int, f func(func(val pot.Val, i int) bool) bool) bool {
 | 
						k.conns.EachBin(base, Pof, o, func(po, size int, f func(func(val pot.Val, i int) bool) bool) bool {
 | 
				
			||||||
		if startPo > 0 && endPo != k.MaxProxDisplay {
 | 
							if startPo > 0 && endPo != k.MaxProxDisplay {
 | 
				
			||||||
@@ -432,15 +432,15 @@ func (k *Kademlia) eachAddr(base []byte, o int, f func(*BzzAddr, int) bool) {
 | 
				
			|||||||
func (k *Kademlia) NeighbourhoodDepth() (depth int) {
 | 
					func (k *Kademlia) NeighbourhoodDepth() (depth int) {
 | 
				
			||||||
	k.lock.RLock()
 | 
						k.lock.RLock()
 | 
				
			||||||
	defer k.lock.RUnlock()
 | 
						defer k.lock.RUnlock()
 | 
				
			||||||
	return depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						return depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// depthForPot returns the proximity order that defines the distance of
 | 
					// depthForPot returns the proximity order that defines the distance of
 | 
				
			||||||
// the nearest neighbour set with cardinality >= MinProxBinSize
 | 
					// the nearest neighbour set with cardinality >= NeighbourhoodSize
 | 
				
			||||||
// if there is altogether less than MinProxBinSize peers it returns 0
 | 
					// if there is altogether less than NeighbourhoodSize peers it returns 0
 | 
				
			||||||
// caller must hold the lock
 | 
					// caller must hold the lock
 | 
				
			||||||
func depthForPot(p *pot.Pot, minProxBinSize int, pivotAddr []byte) (depth int) {
 | 
					func depthForPot(p *pot.Pot, neighbourhoodSize int, pivotAddr []byte) (depth int) {
 | 
				
			||||||
	if p.Size() <= minProxBinSize {
 | 
						if p.Size() <= neighbourhoodSize {
 | 
				
			||||||
		return 0
 | 
							return 0
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -448,7 +448,7 @@ func depthForPot(p *pot.Pot, minProxBinSize int, pivotAddr []byte) (depth int) {
 | 
				
			|||||||
	var size int
 | 
						var size int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// determining the depth is a two-step process
 | 
						// determining the depth is a two-step process
 | 
				
			||||||
	// first we find the proximity bin of the shallowest of the MinProxBinSize peers
 | 
						// first we find the proximity bin of the shallowest of the NeighbourhoodSize peers
 | 
				
			||||||
	// the numeric value of depth cannot be higher than this
 | 
						// the numeric value of depth cannot be higher than this
 | 
				
			||||||
	var maxDepth int
 | 
						var maxDepth int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -461,7 +461,7 @@ func depthForPot(p *pot.Pot, minProxBinSize int, pivotAddr []byte) (depth int) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// this means we have all nn-peers.
 | 
							// this means we have all nn-peers.
 | 
				
			||||||
		// depth is by default set to the bin of the farthest nn-peer
 | 
							// depth is by default set to the bin of the farthest nn-peer
 | 
				
			||||||
		if size == minProxBinSize {
 | 
							if size == neighbourhoodSize {
 | 
				
			||||||
			maxDepth = i
 | 
								maxDepth = i
 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -538,12 +538,12 @@ func (k *Kademlia) string() string {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	rows = append(rows, "=========================================================================")
 | 
						rows = append(rows, "=========================================================================")
 | 
				
			||||||
	rows = append(rows, fmt.Sprintf("%v KΛÐΞMLIΛ hive: queen's address: %x", time.Now().UTC().Format(time.UnixDate), k.BaseAddr()[:3]))
 | 
						rows = append(rows, fmt.Sprintf("%v KΛÐΞMLIΛ hive: queen's address: %x", time.Now().UTC().Format(time.UnixDate), k.BaseAddr()[:3]))
 | 
				
			||||||
	rows = append(rows, fmt.Sprintf("population: %d (%d), MinProxBinSize: %d, MinBinSize: %d, MaxBinSize: %d", k.conns.Size(), k.addrs.Size(), k.MinProxBinSize, k.MinBinSize, k.MaxBinSize))
 | 
						rows = append(rows, fmt.Sprintf("population: %d (%d), NeighbourhoodSize: %d, MinBinSize: %d, MaxBinSize: %d", k.conns.Size(), k.addrs.Size(), k.NeighbourhoodSize, k.MinBinSize, k.MaxBinSize))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	liverows := make([]string, k.MaxProxDisplay)
 | 
						liverows := make([]string, k.MaxProxDisplay)
 | 
				
			||||||
	peersrows := make([]string, k.MaxProxDisplay)
 | 
						peersrows := make([]string, k.MaxProxDisplay)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						depth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
	rest := k.conns.Size()
 | 
						rest := k.conns.Size()
 | 
				
			||||||
	k.conns.EachBin(k.base, Pof, 0, func(po, size int, f func(func(val pot.Val, i int) bool) bool) bool {
 | 
						k.conns.EachBin(k.base, Pof, 0, func(po, size int, f func(func(val pot.Val, i int) bool) bool) bool {
 | 
				
			||||||
		var rowlen int
 | 
							var rowlen int
 | 
				
			||||||
@@ -611,10 +611,10 @@ type PeerPot struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// NewPeerPotMap creates a map of pot record of *BzzAddr with keys
 | 
					// NewPeerPotMap creates a map of pot record of *BzzAddr with keys
 | 
				
			||||||
// as hexadecimal representations of the address.
 | 
					// as hexadecimal representations of the address.
 | 
				
			||||||
// the MinProxBinSize of the passed kademlia is used
 | 
					// the NeighbourhoodSize of the passed kademlia is used
 | 
				
			||||||
// used for testing only
 | 
					// used for testing only
 | 
				
			||||||
// TODO move to separate testing tools file
 | 
					// TODO move to separate testing tools file
 | 
				
			||||||
func NewPeerPotMap(minProxBinSize int, addrs [][]byte) map[string]*PeerPot {
 | 
					func NewPeerPotMap(neighbourhoodSize int, addrs [][]byte) map[string]*PeerPot {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// create a table of all nodes for health check
 | 
						// create a table of all nodes for health check
 | 
				
			||||||
	np := pot.NewPot(nil, 0)
 | 
						np := pot.NewPot(nil, 0)
 | 
				
			||||||
@@ -628,7 +628,7 @@ func NewPeerPotMap(minProxBinSize int, addrs [][]byte) map[string]*PeerPot {
 | 
				
			|||||||
	for i, a := range addrs {
 | 
						for i, a := range addrs {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// actual kademlia depth
 | 
							// actual kademlia depth
 | 
				
			||||||
		depth := depthForPot(np, minProxBinSize, a)
 | 
							depth := depthForPot(np, neighbourhoodSize, a)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// all nn-peers
 | 
							// all nn-peers
 | 
				
			||||||
		var nns [][]byte
 | 
							var nns [][]byte
 | 
				
			||||||
@@ -670,7 +670,7 @@ func (k *Kademlia) saturation() int {
 | 
				
			|||||||
		return prev == po && size >= k.MinBinSize
 | 
							return prev == po && size >= k.MinBinSize
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	// TODO evaluate whether this check cannot just as well be done within the eachbin
 | 
						// TODO evaluate whether this check cannot just as well be done within the eachbin
 | 
				
			||||||
	depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						depth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
	if depth < prev {
 | 
						if depth < prev {
 | 
				
			||||||
		return depth
 | 
							return depth
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -683,7 +683,7 @@ func (k *Kademlia) saturation() int {
 | 
				
			|||||||
// TODO move to separate testing tools file
 | 
					// TODO move to separate testing tools file
 | 
				
			||||||
func (k *Kademlia) knowNeighbours(addrs [][]byte) (got bool, n int, missing [][]byte) {
 | 
					func (k *Kademlia) knowNeighbours(addrs [][]byte) (got bool, n int, missing [][]byte) {
 | 
				
			||||||
	pm := make(map[string]bool)
 | 
						pm := make(map[string]bool)
 | 
				
			||||||
	depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						depth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
	// create a map with all peers at depth and deeper known in the kademlia
 | 
						// create a map with all peers at depth and deeper known in the kademlia
 | 
				
			||||||
	k.eachAddr(nil, 255, func(p *BzzAddr, po int) bool {
 | 
						k.eachAddr(nil, 255, func(p *BzzAddr, po int) bool {
 | 
				
			||||||
		// in order deepest to shallowest compared to the kademlia base address
 | 
							// in order deepest to shallowest compared to the kademlia base address
 | 
				
			||||||
@@ -719,7 +719,11 @@ func (k *Kademlia) knowNeighbours(addrs [][]byte) (got bool, n int, missing [][]
 | 
				
			|||||||
// It is used in Healthy function for testing only
 | 
					// It is used in Healthy function for testing only
 | 
				
			||||||
func (k *Kademlia) connectedNeighbours(peers [][]byte) (got bool, n int, missing [][]byte) {
 | 
					func (k *Kademlia) connectedNeighbours(peers [][]byte) (got bool, n int, missing [][]byte) {
 | 
				
			||||||
	pm := make(map[string]bool)
 | 
						pm := make(map[string]bool)
 | 
				
			||||||
	depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
					
 | 
				
			||||||
 | 
						// create a map with all peers at depth and deeper that are connected in the kademlia
 | 
				
			||||||
 | 
						// in order deepest to shallowest compared to the kademlia base address
 | 
				
			||||||
 | 
						// all bins (except self) are included (0 <= bin <= 255)
 | 
				
			||||||
 | 
						depth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
	k.eachConn(nil, 255, func(p *Peer, po int) bool {
 | 
						k.eachConn(nil, 255, func(p *Peer, po int) bool {
 | 
				
			||||||
		if po < depth {
 | 
							if po < depth {
 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
@@ -772,7 +776,7 @@ func (k *Kademlia) Healthy(pp *PeerPot) *Health {
 | 
				
			|||||||
	defer k.lock.RUnlock()
 | 
						defer k.lock.RUnlock()
 | 
				
			||||||
	gotnn, countgotnn, culpritsgotnn := k.connectedNeighbours(pp.NNSet)
 | 
						gotnn, countgotnn, culpritsgotnn := k.connectedNeighbours(pp.NNSet)
 | 
				
			||||||
	knownn, countknownn, culpritsknownn := k.knowNeighbours(pp.NNSet)
 | 
						knownn, countknownn, culpritsknownn := k.knowNeighbours(pp.NNSet)
 | 
				
			||||||
	depth := depthForPot(k.conns, k.MinProxBinSize, k.base)
 | 
						depth := depthForPot(k.conns, k.NeighbourhoodSize, k.base)
 | 
				
			||||||
	saturated := k.saturation() < depth
 | 
						saturated := k.saturation() < depth
 | 
				
			||||||
	log.Trace(fmt.Sprintf("%08x: healthy: knowNNs: %v, gotNNs: %v, saturated: %v\n", k.base, knownn, gotnn, saturated))
 | 
						log.Trace(fmt.Sprintf("%08x: healthy: knowNNs: %v, gotNNs: %v, saturated: %v\n", k.base, knownn, gotnn, saturated))
 | 
				
			||||||
	return &Health{
 | 
						return &Health{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,7 @@ func newTestKademliaParams() *KadParams {
 | 
				
			|||||||
	params := NewKadParams()
 | 
						params := NewKadParams()
 | 
				
			||||||
	// TODO why is this 1?
 | 
						// TODO why is this 1?
 | 
				
			||||||
	params.MinBinSize = 1
 | 
						params.MinBinSize = 1
 | 
				
			||||||
	params.MinProxBinSize = 2
 | 
						params.NeighbourhoodSize = 2
 | 
				
			||||||
	return params
 | 
						return params
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,7 +87,7 @@ func Register(k *Kademlia, regs ...string) {
 | 
				
			|||||||
// empty bins above the farthest "nearest neighbor-peer" then
 | 
					// empty bins above the farthest "nearest neighbor-peer" then
 | 
				
			||||||
// the depth should be set at the farthest of those empty bins
 | 
					// the depth should be set at the farthest of those empty bins
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// TODO: Make test adapt to change in MinProxBinSize
 | 
					// TODO: Make test adapt to change in NeighbourhoodSize
 | 
				
			||||||
func TestNeighbourhoodDepth(t *testing.T) {
 | 
					func TestNeighbourhoodDepth(t *testing.T) {
 | 
				
			||||||
	baseAddressBytes := RandomAddr().OAddr
 | 
						baseAddressBytes := RandomAddr().OAddr
 | 
				
			||||||
	kad := NewKademlia(baseAddressBytes, NewKadParams())
 | 
						kad := NewKademlia(baseAddressBytes, NewKadParams())
 | 
				
			||||||
@@ -237,7 +237,7 @@ func assertHealth(t *testing.T, k *Kademlia, expectHealthy bool, expectSaturatio
 | 
				
			|||||||
		return true
 | 
							return true
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pp := NewPeerPotMap(k.MinProxBinSize, addrs)
 | 
						pp := NewPeerPotMap(k.NeighbourhoodSize, addrs)
 | 
				
			||||||
	healthParams := k.Healthy(pp[kid])
 | 
						healthParams := k.Healthy(pp[kid])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// definition of health, all conditions but be true:
 | 
						// definition of health, all conditions but be true:
 | 
				
			||||||
@@ -605,7 +605,7 @@ func TestKademliaHiveString(t *testing.T) {
 | 
				
			|||||||
	Register(k, "10000000", "10000001")
 | 
						Register(k, "10000000", "10000001")
 | 
				
			||||||
	k.MaxProxDisplay = 8
 | 
						k.MaxProxDisplay = 8
 | 
				
			||||||
	h := k.String()
 | 
						h := k.String()
 | 
				
			||||||
	expH := "\n=========================================================================\nMon Feb 27 12:10:28 UTC 2017 KΛÐΞMLIΛ hive: queen's address: 000000\npopulation: 2 (4), MinProxBinSize: 2, MinBinSize: 1, MaxBinSize: 4\n============ DEPTH: 0 ==========================================\n000  0                              |  2 8100 (0) 8000 (0)\n001  1 4000                         |  1 4000 (0)\n002  1 2000                         |  1 2000 (0)\n003  0                              |  0\n004  0                              |  0\n005  0                              |  0\n006  0                              |  0\n007  0                              |  0\n========================================================================="
 | 
						expH := "\n=========================================================================\nMon Feb 27 12:10:28 UTC 2017 KΛÐΞMLIΛ hive: queen's address: 000000\npopulation: 2 (4), NeighbourhoodSize: 2, MinBinSize: 1, MaxBinSize: 4\n============ DEPTH: 0 ==========================================\n000  0                              |  2 8100 (0) 8000 (0)\n001  1 4000                         |  1 4000 (0)\n002  1 2000                         |  1 2000 (0)\n003  0                              |  0\n004  0                              |  0\n005  0                              |  0\n006  0                              |  0\n007  0                              |  0\n========================================================================="
 | 
				
			||||||
	if expH[104:] != h[104:] {
 | 
						if expH[104:] != h[104:] {
 | 
				
			||||||
		t.Fatalf("incorrect hive output. expected %v, got %v", expH, h)
 | 
							t.Fatalf("incorrect hive output. expected %v, got %v", expH, h)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -636,7 +636,7 @@ func testKademliaCase(t *testing.T, pivotAddr string, addrs ...string) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ppmap := NewPeerPotMap(k.MinProxBinSize, byteAddrs)
 | 
						ppmap := NewPeerPotMap(k.NeighbourhoodSize, byteAddrs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pp := ppmap[pivotAddr]
 | 
						pp := ppmap[pivotAddr]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -662,7 +662,7 @@ in higher level tests for streaming. They were generated randomly.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
=========================================================================
 | 
					=========================================================================
 | 
				
			||||||
Mon Apr  9 12:18:24 UTC 2018 KΛÐΞMLIΛ hive: queen's address: 7efef1
 | 
					Mon Apr  9 12:18:24 UTC 2018 KΛÐΞMLIΛ hive: queen's address: 7efef1
 | 
				
			||||||
population: 9 (49), MinProxBinSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
					population: 9 (49), NeighbourhoodSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
				
			||||||
000  2 d7e5 ec56                    | 18 ec56 (0) d7e5 (0) d9e0 (0) c735 (0)
 | 
					000  2 d7e5 ec56                    | 18 ec56 (0) d7e5 (0) d9e0 (0) c735 (0)
 | 
				
			||||||
001  2 18f1 3176                    | 14 18f1 (0) 10bb (0) 10d1 (0) 0421 (0)
 | 
					001  2 18f1 3176                    | 14 18f1 (0) 10bb (0) 10d1 (0) 0421 (0)
 | 
				
			||||||
002  2 52aa 47cd                    | 11 52aa (0) 51d9 (0) 5161 (0) 5130 (0)
 | 
					002  2 52aa 47cd                    | 11 52aa (0) 51d9 (0) 5161 (0) 5130 (0)
 | 
				
			||||||
@@ -745,7 +745,7 @@ in higher level tests for streaming. They were generated randomly.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
=========================================================================
 | 
					=========================================================================
 | 
				
			||||||
Mon Apr  9 18:43:48 UTC 2018 KΛÐΞMLIΛ hive: queen's address: bc7f3b
 | 
					Mon Apr  9 18:43:48 UTC 2018 KΛÐΞMLIΛ hive: queen's address: bc7f3b
 | 
				
			||||||
population: 9 (49), MinProxBinSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
					population: 9 (49), NeighbourhoodSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
				
			||||||
000  2 0f49 67ff                    | 28 0f49 (0) 0211 (0) 07b2 (0) 0703 (0)
 | 
					000  2 0f49 67ff                    | 28 0f49 (0) 0211 (0) 07b2 (0) 0703 (0)
 | 
				
			||||||
001  2 e84b f3a4                    | 13 f3a4 (0) e84b (0) e58b (0) e60b (0)
 | 
					001  2 e84b f3a4                    | 13 f3a4 (0) e84b (0) e58b (0) e60b (0)
 | 
				
			||||||
002  1 8dba                         |  1 8dba (0)
 | 
					002  1 8dba                         |  1 8dba (0)
 | 
				
			||||||
@@ -779,7 +779,7 @@ in higher level tests for streaming. They were generated randomly.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
=========================================================================
 | 
					=========================================================================
 | 
				
			||||||
Mon Apr  9 19:04:35 UTC 2018 KΛÐΞMLIΛ hive: queen's address: b4822e
 | 
					Mon Apr  9 19:04:35 UTC 2018 KΛÐΞMLIΛ hive: queen's address: b4822e
 | 
				
			||||||
population: 8 (49), MinProxBinSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
					population: 8 (49), NeighbourhoodSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
				
			||||||
000  2 786c 774b                    | 29 774b (0) 786c (0) 7a79 (0) 7d2f (0)
 | 
					000  2 786c 774b                    | 29 774b (0) 786c (0) 7a79 (0) 7d2f (0)
 | 
				
			||||||
001  2 d9de cf19                    | 10 cf19 (0) d9de (0) d2ff (0) d2a2 (0)
 | 
					001  2 d9de cf19                    | 10 cf19 (0) d9de (0) d2ff (0) d2a2 (0)
 | 
				
			||||||
002  2 8ca1 8d74                    |  5 8d74 (0) 8ca1 (0) 9793 (0) 9f51 (0)
 | 
					002  2 8ca1 8d74                    |  5 8d74 (0) 8ca1 (0) 9793 (0) 9f51 (0)
 | 
				
			||||||
@@ -813,7 +813,7 @@ in higher level tests for streaming. They were generated randomly.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
=========================================================================
 | 
					=========================================================================
 | 
				
			||||||
Mon Apr  9 19:16:25 UTC 2018 KΛÐΞMLIΛ hive: queen's address: 9a90fe
 | 
					Mon Apr  9 19:16:25 UTC 2018 KΛÐΞMLIΛ hive: queen's address: 9a90fe
 | 
				
			||||||
population: 8 (49), MinProxBinSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
					population: 8 (49), NeighbourhoodSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
				
			||||||
000  2 72ef 4e6c                    | 24 0b1e (0) 0d66 (0) 17f5 (0) 17e8 (0)
 | 
					000  2 72ef 4e6c                    | 24 0b1e (0) 0d66 (0) 17f5 (0) 17e8 (0)
 | 
				
			||||||
001  2 fc2b fa47                    | 13 fa47 (0) fc2b (0) fffd (0) ecef (0)
 | 
					001  2 fc2b fa47                    | 13 fa47 (0) fc2b (0) fffd (0) ecef (0)
 | 
				
			||||||
002  2 b847 afa8                    |  6 afa8 (0) ad77 (0) bb7c (0) b847 (0)
 | 
					002  2 b847 afa8                    |  6 afa8 (0) ad77 (0) bb7c (0) b847 (0)
 | 
				
			||||||
@@ -848,7 +848,7 @@ in higher level tests for streaming. They were generated randomly.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
=========================================================================
 | 
					=========================================================================
 | 
				
			||||||
Mon Apr  9 19:25:18 UTC 2018 KΛÐΞMLIΛ hive: queen's address: 5dd5c7
 | 
					Mon Apr  9 19:25:18 UTC 2018 KΛÐΞMLIΛ hive: queen's address: 5dd5c7
 | 
				
			||||||
population: 13 (49), MinProxBinSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
					population: 13 (49), NeighbourhoodSize: 2, MinBinSize: 2, MaxBinSize: 4
 | 
				
			||||||
000  2 e528 fad0                    | 22 fad0 (0) e528 (0) e3bb (0) ed13 (0)
 | 
					000  2 e528 fad0                    | 22 fad0 (0) e528 (0) e3bb (0) ed13 (0)
 | 
				
			||||||
001  3 3f30 18e0 1dd3               |  7 3f30 (0) 23db (0) 10b6 (0) 18e0 (0)
 | 
					001  3 3f30 18e0 1dd3               |  7 3f30 (0) 23db (0) 10b6 (0) 18e0 (0)
 | 
				
			||||||
002  4 7c54 7804 61e4 60f9          | 10 61e4 (0) 60f9 (0) 636c (0) 7186 (0)
 | 
					002  4 7c54 7804 61e4 60f9          | 10 61e4 (0) 60f9 (0) 636c (0) 7186 (0)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -188,7 +188,7 @@ func newServices() adapters.Services {
 | 
				
			|||||||
			return k
 | 
								return k
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		params := NewKadParams()
 | 
							params := NewKadParams()
 | 
				
			||||||
		params.MinProxBinSize = 2
 | 
							params.NeighbourhoodSize = 2
 | 
				
			||||||
		params.MaxBinSize = 3
 | 
							params.MaxBinSize = 3
 | 
				
			||||||
		params.MinBinSize = 1
 | 
							params.MinBinSize = 1
 | 
				
			||||||
		params.MaxRetries = 1000
 | 
							params.MaxRetries = 1000
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,8 +18,14 @@ package simulation_test
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"sync"
 | 
				
			||||||
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/ethereum/go-ethereum/log"
 | 
						"github.com/ethereum/go-ethereum/log"
 | 
				
			||||||
 | 
						"github.com/ethereum/go-ethereum/node"
 | 
				
			||||||
 | 
						"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
 | 
				
			||||||
 | 
						"github.com/ethereum/go-ethereum/swarm/network"
 | 
				
			||||||
	"github.com/ethereum/go-ethereum/swarm/network/simulation"
 | 
						"github.com/ethereum/go-ethereum/swarm/network/simulation"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -28,10 +34,6 @@ import (
 | 
				
			|||||||
// all nodes have the their Kademlias healthy.
 | 
					// all nodes have the their Kademlias healthy.
 | 
				
			||||||
func ExampleSimulation_WaitTillHealthy() {
 | 
					func ExampleSimulation_WaitTillHealthy() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log.Error("temporarily disabled as simulations.WaitTillHealthy cannot be trusted")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Commented out to avoid go vet errors/warnings
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sim := simulation.New(map[string]simulation.ServiceFunc{
 | 
						sim := simulation.New(map[string]simulation.ServiceFunc{
 | 
				
			||||||
		"bzz": func(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, func(), error) {
 | 
							"bzz": func(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, func(), error) {
 | 
				
			||||||
			addr := network.NewAddr(ctx.Config.Node())
 | 
								addr := network.NewAddr(ctx.Config.Node())
 | 
				
			||||||
@@ -59,7 +61,7 @@ func ExampleSimulation_WaitTillHealthy() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
 | 
						ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
 | 
				
			||||||
	defer cancel()
 | 
						defer cancel()
 | 
				
			||||||
	ill, err := sim.WaitTillHealthy(ctx, 2)
 | 
						ill, err := sim.WaitTillHealthy(ctx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		// inspect the latest detected not healthy kademlias
 | 
							// inspect the latest detected not healthy kademlias
 | 
				
			||||||
		for id, kad := range ill {
 | 
							for id, kad := range ill {
 | 
				
			||||||
@@ -71,7 +73,6 @@ func ExampleSimulation_WaitTillHealthy() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// continue with the test
 | 
						// continue with the test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Watch all peer events in the simulation network, buy receiving from a channel.
 | 
					// Watch all peer events in the simulation network, buy receiving from a channel.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,7 @@ var BucketKeyKademlia BucketKey = "kademlia"
 | 
				
			|||||||
// WaitTillHealthy is blocking until the health of all kademlias is true.
 | 
					// WaitTillHealthy is blocking until the health of all kademlias is true.
 | 
				
			||||||
// If error is not nil, a map of kademlia that was found not healthy is returned.
 | 
					// If error is not nil, a map of kademlia that was found not healthy is returned.
 | 
				
			||||||
// TODO: Check correctness since change in kademlia depth calculation logic
 | 
					// TODO: Check correctness since change in kademlia depth calculation logic
 | 
				
			||||||
func (s *Simulation) WaitTillHealthy(ctx context.Context, kadMinProxSize int) (ill map[enode.ID]*network.Kademlia, err error) {
 | 
					func (s *Simulation) WaitTillHealthy(ctx context.Context) (ill map[enode.ID]*network.Kademlia, err error) {
 | 
				
			||||||
	// Prepare PeerPot map for checking Kademlia health
 | 
						// Prepare PeerPot map for checking Kademlia health
 | 
				
			||||||
	var ppmap map[string]*network.PeerPot
 | 
						var ppmap map[string]*network.PeerPot
 | 
				
			||||||
	kademlias := s.kademlias()
 | 
						kademlias := s.kademlias()
 | 
				
			||||||
@@ -43,7 +43,7 @@ func (s *Simulation) WaitTillHealthy(ctx context.Context, kadMinProxSize int) (i
 | 
				
			|||||||
	for _, k := range kademlias {
 | 
						for _, k := range kademlias {
 | 
				
			||||||
		addrs = append(addrs, k.BaseAddr())
 | 
							addrs = append(addrs, k.BaseAddr())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	ppmap = network.NewPeerPotMap(kadMinProxSize, addrs)
 | 
						ppmap = network.NewPeerPotMap(s.neighbourhoodSize, addrs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Wait for healthy Kademlia on every node before checking files
 | 
						// Wait for healthy Kademlia on every node before checking files
 | 
				
			||||||
	ticker := time.NewTicker(200 * time.Millisecond)
 | 
						ticker := time.NewTicker(200 * time.Millisecond)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestWaitTillHealthy(t *testing.T) {
 | 
					func TestWaitTillHealthy(t *testing.T) {
 | 
				
			||||||
 | 
						t.Skip("WaitTillHealthy depends on discovery, which relies on a reliable SuggestPeer, which is not reliable")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sim := New(map[string]ServiceFunc{
 | 
						sim := New(map[string]ServiceFunc{
 | 
				
			||||||
		"bzz": func(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, func(), error) {
 | 
							"bzz": func(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, func(), error) {
 | 
				
			||||||
@@ -54,7 +55,7 @@ func TestWaitTillHealthy(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 | 
						ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
 | 
				
			||||||
	defer cancel()
 | 
						defer cancel()
 | 
				
			||||||
	ill, err := sim.WaitTillHealthy(ctx, 2)
 | 
						ill, err := sim.WaitTillHealthy(ctx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		for id, kad := range ill {
 | 
							for id, kad := range ill {
 | 
				
			||||||
			t.Log("Node", id)
 | 
								t.Log("Node", id)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
	"github.com/ethereum/go-ethereum/p2p/enode"
 | 
						"github.com/ethereum/go-ethereum/p2p/enode"
 | 
				
			||||||
	"github.com/ethereum/go-ethereum/p2p/simulations"
 | 
						"github.com/ethereum/go-ethereum/p2p/simulations"
 | 
				
			||||||
	"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
 | 
						"github.com/ethereum/go-ethereum/p2p/simulations/adapters"
 | 
				
			||||||
 | 
						"github.com/ethereum/go-ethereum/swarm/network"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Common errors that are returned by functions in this package.
 | 
					// Common errors that are returned by functions in this package.
 | 
				
			||||||
@@ -49,6 +50,7 @@ type Simulation struct {
 | 
				
			|||||||
	shutdownWG        sync.WaitGroup
 | 
						shutdownWG        sync.WaitGroup
 | 
				
			||||||
	done              chan struct{}
 | 
						done              chan struct{}
 | 
				
			||||||
	mu                sync.RWMutex
 | 
						mu                sync.RWMutex
 | 
				
			||||||
 | 
						neighbourhoodSize int
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	httpSrv *http.Server        //attach a HTTP server via SimulationOptions
 | 
						httpSrv *http.Server        //attach a HTTP server via SimulationOptions
 | 
				
			||||||
	handler *simulations.Server //HTTP handler for the server
 | 
						handler *simulations.Server //HTTP handler for the server
 | 
				
			||||||
@@ -74,6 +76,7 @@ func New(services map[string]ServiceFunc) (s *Simulation) {
 | 
				
			|||||||
	s = &Simulation{
 | 
						s = &Simulation{
 | 
				
			||||||
		buckets:           make(map[enode.ID]*sync.Map),
 | 
							buckets:           make(map[enode.ID]*sync.Map),
 | 
				
			||||||
		done:              make(chan struct{}),
 | 
							done:              make(chan struct{}),
 | 
				
			||||||
 | 
							neighbourhoodSize: network.NewKadParams().NeighbourhoodSize,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	adapterServices := make(map[string]adapters.ServiceFunc, len(services))
 | 
						adapterServices := make(map[string]adapters.ServiceFunc, len(services))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ import (
 | 
				
			|||||||
// serviceName is used with the exec adapter so the exec'd binary knows which
 | 
					// serviceName is used with the exec adapter so the exec'd binary knows which
 | 
				
			||||||
// service to execute
 | 
					// service to execute
 | 
				
			||||||
const serviceName = "discovery"
 | 
					const serviceName = "discovery"
 | 
				
			||||||
const testMinProxBinSize = 2
 | 
					const testNeighbourhoodSize = 2
 | 
				
			||||||
const discoveryPersistenceDatadir = "discovery_persistence_test_store"
 | 
					const discoveryPersistenceDatadir = "discovery_persistence_test_store"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var discoveryPersistencePath = path.Join(os.TempDir(), discoveryPersistenceDatadir)
 | 
					var discoveryPersistencePath = path.Join(os.TempDir(), discoveryPersistenceDatadir)
 | 
				
			||||||
@@ -268,7 +268,7 @@ func discoverySimulation(nodes, conns int, adapter adapters.NodeAdapter) (*simul
 | 
				
			|||||||
	wg.Wait()
 | 
						wg.Wait()
 | 
				
			||||||
	log.Debug(fmt.Sprintf("nodes: %v", len(addrs)))
 | 
						log.Debug(fmt.Sprintf("nodes: %v", len(addrs)))
 | 
				
			||||||
	// construct the peer pot, so that kademlia health can be checked
 | 
						// construct the peer pot, so that kademlia health can be checked
 | 
				
			||||||
	ppmap := network.NewPeerPotMap(network.NewKadParams().MinProxBinSize, addrs)
 | 
						ppmap := network.NewPeerPotMap(network.NewKadParams().NeighbourhoodSize, addrs)
 | 
				
			||||||
	check := func(ctx context.Context, id enode.ID) (bool, error) {
 | 
						check := func(ctx context.Context, id enode.ID) (bool, error) {
 | 
				
			||||||
		select {
 | 
							select {
 | 
				
			||||||
		case <-ctx.Done():
 | 
							case <-ctx.Done():
 | 
				
			||||||
@@ -404,7 +404,7 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
				healthy := &network.Health{}
 | 
									healthy := &network.Health{}
 | 
				
			||||||
				addr := id.String()
 | 
									addr := id.String()
 | 
				
			||||||
				ppmap := network.NewPeerPotMap(network.NewKadParams().MinProxBinSize, addrs)
 | 
									ppmap := network.NewPeerPotMap(network.NewKadParams().NeighbourhoodSize, addrs)
 | 
				
			||||||
				if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil {
 | 
									if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil {
 | 
				
			||||||
					return fmt.Errorf("error getting node health: %s", err)
 | 
										return fmt.Errorf("error getting node health: %s", err)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -492,7 +492,7 @@ func discoveryPersistenceSimulation(nodes, conns int, adapter adapters.NodeAdapt
 | 
				
			|||||||
			return false, fmt.Errorf("error getting node client: %s", err)
 | 
								return false, fmt.Errorf("error getting node client: %s", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		healthy := &network.Health{}
 | 
							healthy := &network.Health{}
 | 
				
			||||||
		ppmap := network.NewPeerPotMap(network.NewKadParams().MinProxBinSize, addrs)
 | 
							ppmap := network.NewPeerPotMap(network.NewKadParams().NeighbourhoodSize, addrs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil {
 | 
							if err := client.Call(&healthy, "hive_healthy", ppmap); err != nil {
 | 
				
			||||||
			return false, fmt.Errorf("error getting node health: %s", err)
 | 
								return false, fmt.Errorf("error getting node health: %s", err)
 | 
				
			||||||
@@ -566,7 +566,7 @@ func newService(ctx *adapters.ServiceContext) (node.Service, error) {
 | 
				
			|||||||
	addr := network.NewAddr(ctx.Config.Node())
 | 
						addr := network.NewAddr(ctx.Config.Node())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kp := network.NewKadParams()
 | 
						kp := network.NewKadParams()
 | 
				
			||||||
	kp.MinProxBinSize = testMinProxBinSize
 | 
						kp.NeighbourhoodSize = testNeighbourhoodSize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ctx.Config.Reachable != nil {
 | 
						if ctx.Config.Reachable != nil {
 | 
				
			||||||
		kp.Reachable = func(o *network.BzzAddr) bool {
 | 
							kp.Reachable = func(o *network.BzzAddr) bool {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,7 +86,7 @@ func (s *Simulation) NewService(ctx *adapters.ServiceContext) (node.Service, err
 | 
				
			|||||||
	addr := network.NewAddr(node)
 | 
						addr := network.NewAddr(node)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kp := network.NewKadParams()
 | 
						kp := network.NewKadParams()
 | 
				
			||||||
	kp.MinProxBinSize = 2
 | 
						kp.NeighbourhoodSize = 2
 | 
				
			||||||
	kp.MaxBinSize = 4
 | 
						kp.MaxBinSize = 4
 | 
				
			||||||
	kp.MinBinSize = 1
 | 
						kp.MinBinSize = 1
 | 
				
			||||||
	kp.MaxRetries = 1000
 | 
						kp.MaxRetries = 1000
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -544,7 +544,7 @@ func testDeliveryFromNodes(t *testing.T, nodes, chunkCount int, skipCheck bool)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		log.Debug("Waiting for kademlia")
 | 
							log.Debug("Waiting for kademlia")
 | 
				
			||||||
		// TODO this does not seem to be correct usage of the function, as the simulation may have no kademlias
 | 
							// TODO this does not seem to be correct usage of the function, as the simulation may have no kademlias
 | 
				
			||||||
		if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
							if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -704,7 +704,7 @@ func benchmarkDeliveryFromNodes(b *testing.B, nodes, chunkCount int, skipCheck b
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		netStore := item.(*storage.NetStore)
 | 
							netStore := item.(*storage.NetStore)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
							if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,7 +115,7 @@ func testIntervals(t *testing.T, live bool, history *Range, skipCheck bool) {
 | 
				
			|||||||
	ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
 | 
						ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
 | 
				
			||||||
	defer cancel()
 | 
						defer cancel()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
						if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -197,7 +197,7 @@ func runFileRetrievalTest(nodeCount int) error {
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
							if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -287,7 +287,7 @@ func runRetrievalTest(chunkCount int, nodeCount int) error {
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
							if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -204,7 +204,7 @@ func testSyncingViaGlobalSync(t *testing.T, chunkCount int, nodeCount int) {
 | 
				
			|||||||
	ctx, cancelSimRun := context.WithTimeout(context.Background(), 2*time.Minute)
 | 
						ctx, cancelSimRun := context.WithTimeout(context.Background(), 2*time.Minute)
 | 
				
			||||||
	defer cancelSimRun()
 | 
						defer cancelSimRun()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
						if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
		t.Fatal(err)
 | 
							t.Fatal(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -391,7 +391,7 @@ func testSyncingViaDirectSubscribe(t *testing.T, chunkCount int, nodeCount int)
 | 
				
			|||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
						if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -471,7 +471,7 @@ func testSyncingViaDirectSubscribe(t *testing.T, chunkCount int, nodeCount int)
 | 
				
			|||||||
		conf.hashes = append(conf.hashes, hashes...)
 | 
							conf.hashes = append(conf.hashes, hashes...)
 | 
				
			||||||
		mapKeysToNodes(conf)
 | 
							mapKeysToNodes(conf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
							if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -563,7 +563,7 @@ func mapKeysToNodes(conf *synctestConfig) {
 | 
				
			|||||||
		np, _, _ = pot.Add(np, a, pof)
 | 
							np, _, _ = pot.Add(np, a, pof)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ppmap := network.NewPeerPotMap(network.NewKadParams().MinProxBinSize, conf.addrs)
 | 
						ppmap := network.NewPeerPotMap(network.NewKadParams().NeighbourhoodSize, conf.addrs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//for each address, run EachNeighbour on the chunk hashes pot to identify closest nodes
 | 
						//for each address, run EachNeighbour on the chunk hashes pot to identify closest nodes
 | 
				
			||||||
	log.Trace(fmt.Sprintf("Generated hash chunk(s): %v", conf.hashes))
 | 
						log.Trace(fmt.Sprintf("Generated hash chunk(s): %v", conf.hashes))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -189,7 +189,7 @@ func testSyncBetweenNodes(t *testing.T, nodes, chunkCount int, skipCheck bool, p
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// here we distribute chunks of a random file into stores 1...nodes
 | 
							// here we distribute chunks of a random file into stores 1...nodes
 | 
				
			||||||
		if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
							if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,7 +72,7 @@ func setupSim(serviceMap map[string]simulation.ServiceFunc) (int, int, *simulati
 | 
				
			|||||||
func watchSim(sim *simulation.Simulation) (context.Context, context.CancelFunc) {
 | 
					func watchSim(sim *simulation.Simulation) (context.Context, context.CancelFunc) {
 | 
				
			||||||
	ctx, cancelSimRun := context.WithTimeout(context.Background(), 1*time.Minute)
 | 
						ctx, cancelSimRun := context.WithTimeout(context.Background(), 1*time.Minute)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
						if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -353,7 +353,7 @@ func testSwarmNetwork(t *testing.T, o *testSwarmNetworkOptions, steps ...testSwa
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if *waitKademlia {
 | 
								if *waitKademlia {
 | 
				
			||||||
				if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
 | 
									if _, err := sim.WaitTillHealthy(ctx); err != nil {
 | 
				
			||||||
					return err
 | 
										return err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -238,7 +238,7 @@ func newServices() adapters.Services {
 | 
				
			|||||||
			return k
 | 
								return k
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		params := network.NewKadParams()
 | 
							params := network.NewKadParams()
 | 
				
			||||||
		params.MinProxBinSize = 2
 | 
							params.NeighbourhoodSize = 2
 | 
				
			||||||
		params.MaxBinSize = 3
 | 
							params.MaxBinSize = 3
 | 
				
			||||||
		params.MinBinSize = 1
 | 
							params.MinBinSize = 1
 | 
				
			||||||
		params.MaxRetries = 1000
 | 
							params.MaxRetries = 1000
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -209,7 +209,7 @@ func newServices(allowRaw bool) adapters.Services {
 | 
				
			|||||||
			return k
 | 
								return k
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		params := network.NewKadParams()
 | 
							params := network.NewKadParams()
 | 
				
			||||||
		params.MinProxBinSize = 2
 | 
							params.NeighbourhoodSize = 2
 | 
				
			||||||
		params.MaxBinSize = 3
 | 
							params.MaxBinSize = 3
 | 
				
			||||||
		params.MinBinSize = 1
 | 
							params.MinBinSize = 1
 | 
				
			||||||
		params.MaxRetries = 1000
 | 
							params.MaxRetries = 1000
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1965,7 +1965,7 @@ func newServices(allowRaw bool) adapters.Services {
 | 
				
			|||||||
			return k
 | 
								return k
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		params := network.NewKadParams()
 | 
							params := network.NewKadParams()
 | 
				
			||||||
		params.MinProxBinSize = 2
 | 
							params.NeighbourhoodSize = 2
 | 
				
			||||||
		params.MaxBinSize = 3
 | 
							params.MaxBinSize = 3
 | 
				
			||||||
		params.MinBinSize = 1
 | 
							params.MinBinSize = 1
 | 
				
			||||||
		params.MaxRetries = 1000
 | 
							params.MaxRetries = 1000
 | 
				
			||||||
@@ -2045,7 +2045,7 @@ func newTestPss(privkey *ecdsa.PrivateKey, kad *network.Kademlia, ppextra *PssPa
 | 
				
			|||||||
	// set up routing if kademlia is not passed to us
 | 
						// set up routing if kademlia is not passed to us
 | 
				
			||||||
	if kad == nil {
 | 
						if kad == nil {
 | 
				
			||||||
		kp := network.NewKadParams()
 | 
							kp := network.NewKadParams()
 | 
				
			||||||
		kp.MinProxBinSize = 3
 | 
							kp.NeighbourhoodSize = 3
 | 
				
			||||||
		kad = network.NewKademlia(nid[:], kp)
 | 
							kad = network.NewKademlia(nid[:], kp)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user