diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-04-24 00:24:48 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-04-24 16:23:20 +0800 |
commit | af923c965ff7a4e652d5c9edabc50f7a03e1135d (patch) | |
tree | d2edf513b14a18e39815a4c68ef221c67ccf4b96 /p2p/discover/table.go | |
parent | 5f735d6fce10b4552b0a6d3eb6503c5a302f4f61 (diff) | |
download | go-tangerine-af923c965ff7a4e652d5c9edabc50f7a03e1135d.tar.gz go-tangerine-af923c965ff7a4e652d5c9edabc50f7a03e1135d.tar.zst go-tangerine-af923c965ff7a4e652d5c9edabc50f7a03e1135d.zip |
p2p/discovery: use the seed table for finding nodes, auto drop stale ones
Diffstat (limited to 'p2p/discover/table.go')
-rw-r--r-- | p2p/discover/table.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 3702a2114..fa791c9f3 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -177,8 +177,14 @@ func (tab *Table) refresh() { result := tab.Lookup(randomID(tab.self.ID, ld)) if len(result) == 0 { - // bootstrap the table with a self lookup - all := tab.bondall(tab.nursery) + // Pick a batch of previously know seeds to lookup with and discard them (will come back if they are still live) + seeds := tab.db.list(10) + for _, seed := range seeds { + glog.V(logger.Debug).Infoln("Seeding network with:", seed) + tab.db.delete(seed.ID) + } + // Bootstrap the table with a self lookup + all := tab.bondall(append(tab.nursery, seeds...)) tab.mutex.Lock() tab.add(all) tab.mutex.Unlock() |