aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/discover/table.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-06-10 19:07:30 +0800
committerFelix Lange <fjl@twurst.com>2015-06-10 19:08:21 +0800
commit261a8077c410c50999d662bd1ca871b7ef414909 (patch)
treec27680cf5190bd60b96f47732ac4bc5b9d7b0289 /p2p/discover/table.go
parentdffe6d32d6d80078f2ecd3330c311ee85c5e9de2 (diff)
downloaddexon-261a8077c410c50999d662bd1ca871b7ef414909.tar
dexon-261a8077c410c50999d662bd1ca871b7ef414909.tar.gz
dexon-261a8077c410c50999d662bd1ca871b7ef414909.tar.bz2
dexon-261a8077c410c50999d662bd1ca871b7ef414909.tar.lz
dexon-261a8077c410c50999d662bd1ca871b7ef414909.tar.xz
dexon-261a8077c410c50999d662bd1ca871b7ef414909.tar.zst
dexon-261a8077c410c50999d662bd1ca871b7ef414909.zip
p2p/discover: deflake TestUDP_successfulPing
Diffstat (limited to 'p2p/discover/table.go')
-rw-r--r--p2p/discover/table.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go
index 4b7ddb775..f71320425 100644
--- a/p2p/discover/table.go
+++ b/p2p/discover/table.go
@@ -40,6 +40,8 @@ type Table struct {
bonding map[NodeID]*bondproc
bondslots chan struct{} // limits total number of active bonding processes
+ nodeAddedHook func(*Node) // for testing
+
net transport
self *Node // metadata of the local node
}
@@ -431,6 +433,9 @@ func (tab *Table) pingreplace(new *Node, b *bucket) {
}
copy(b.entries[1:], b.entries)
b.entries[0] = new
+ if tab.nodeAddedHook != nil {
+ tab.nodeAddedHook(new)
+ }
}
// ping a remote endpoint and wait for a reply, also updating the node database
@@ -466,6 +471,9 @@ outer:
}
if len(bucket.entries) < bucketSize {
bucket.entries = append(bucket.entries, n)
+ if tab.nodeAddedHook != nil {
+ tab.nodeAddedHook(n)
+ }
}
}
}