diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-05-25 21:23:16 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-05-27 05:30:40 +0800 |
commit | 3630432dfb486a5bf8f853900be1fe32fefae182 (patch) | |
tree | 4d57d07a88f0d7d1cb2c0b208934128884753bd4 /p2p/discover/table.go | |
parent | f539ed1e6647cb27d873ae12e48db66df93df34a (diff) | |
download | dexon-3630432dfb486a5bf8f853900be1fe32fefae182.tar.gz dexon-3630432dfb486a5bf8f853900be1fe32fefae182.tar.zst dexon-3630432dfb486a5bf8f853900be1fe32fefae182.zip |
p2p/discovery: fix a cornercase loop if no seeds or bootnodes are known
Diffstat (limited to 'p2p/discover/table.go')
-rw-r--r-- | p2p/discover/table.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 38bdea0ca..7bff0d1d0 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -278,12 +278,16 @@ func (tab *Table) refresh() { for _, seed := range seeds { glog.V(logger.Debug).Infoln("Seeding network with", seed) } + peers := append(tab.nursery, seeds...) + // Bootstrap the table with a self lookup - all := tab.bondall(append(tab.nursery, seeds...)) - tab.mutex.Lock() - tab.add(all) - tab.mutex.Unlock() - tab.Lookup(tab.self.ID) + if len(peers) > 0 { + tab.mutex.Lock() + tab.add(peers) + tab.mutex.Unlock() + + tab.Lookup(tab.self.ID) + } // TODO: the Kademlia paper says that we're supposed to perform // random lookups in all buckets further away than our closest neighbor. } |