Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swarm/network: Cleanup after rebase on upstream cosmetic changes
Browse files Browse the repository at this point in the history
nolash committed Dec 21, 2018
1 parent b5cb505 commit 72dae51
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions swarm/network/kademlia.go
Original file line number Diff line number Diff line change
@@ -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,20 +820,21 @@ 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))
potent := countknownn == 0 || len(impotentBins) == 0
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(),
}
}
2 changes: 1 addition & 1 deletion swarm/network/kademlia_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 72dae51

Please sign in to comment.