From 1ffe2d8a27d0318744f17091a9da8f147e8b4ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 25 May 2015 16:23:16 +0300 Subject: [PATCH] p2p/discovery: fix a cornercase loop if no seeds or bootnodes are known --- p2p/discover/table.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/p2p/discover/table.go b/p2p/discover/table.go index 897bcd84f4..d486a88ecd 100644 --- a/p2p/discover/table.go +++ b/p2p/discover/table.go @@ -229,12 +229,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. }