diff --git a/swarm/network/kademlia.go b/swarm/network/kademlia.go index be8f43d7ce..d300a663a9 100644 --- a/swarm/network/kademlia.go +++ b/swarm/network/kademlia.go @@ -804,7 +804,8 @@ type Health struct { ConnectNN bool // whether node is connected to all its neighbours CountConnectNN int // amount of neighbours connected to MissingConnectNN [][]byte // which neighbours we should have been connected to but we're not - Saturated bool // whether we are connected to all the peers we would have liked to + Potent bool // whether we are connected a mininum of peers for bins we know of peers + Saturation int // whether we are connected to all the peers we would have liked to Hive string } @@ -819,8 +820,8 @@ type Health struct { func (k *Kademlia) Healthy(pp *PeerPot) *Health { k.lock.RLock() defer k.lock.RUnlock() - connectnn, countconnectnn, culpritsconnectnn := k.connectedNeighbours(pp.NNSet) - knownn, countknownn, culpritsknownn := k.knowNeighbours(pp.NNSet) + connectnn, countconnectnn, missingconnectnn := k.connectedNeighbours(pp.NNSet) + knownn, countknownn, missingknownn := k.knowNeighbours(pp.NNSet) impotentBins := k.connectedPotential() saturation := k.saturation() log.Trace(fmt.Sprintf("%08x: healthy: knowNNs: %v, connectNNs: %v, saturated: %v\n", k.base, knownn, connectnn, saturation)) @@ -828,11 +829,12 @@ func (k *Kademlia) Healthy(pp *PeerPot) *Health { return &Health{ KnowNN: knownn, CountKnowNN: countknownn, - MissingKnowNN: culpritsknownn, - ConnectNN: gotnn, - CountConnectNN: countgotnn, - MissingConnectNN: culpritsgotnn, - Saturated: saturated, + MissingKnowNN: missingknownn, + ConnectNN: connectnn, + CountConnectNN: countconnectnn, + MissingConnectNN: missingconnectnn, + Potent: potent, + Saturation: saturation, Hive: k.string(), } } diff --git a/swarm/network/kademlia_test.go b/swarm/network/kademlia_test.go index 12feff08ac..5f61184db2 100644 --- a/swarm/network/kademlia_test.go +++ b/swarm/network/kademlia_test.go @@ -745,7 +745,7 @@ func TestKademliaHiveString(t *testing.T) { Register(k, "10000000", "10000001") k.MaxProxDisplay = 8 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), MinProxBinSize: 2, MinBinSize: 2, 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:] { t.Fatalf("incorrect hive output. expected %v, got %v", expH, h) }