Skip to content

Commit 3630432

Browse files
karalabefjl
authored andcommitted
p2p/discovery: fix a cornercase loop if no seeds or bootnodes are known
1 parent f539ed1 commit 3630432

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

p2p/discover/table.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,16 @@ func (tab *Table) refresh() {
278278
for _, seed := range seeds {
279279
glog.V(logger.Debug).Infoln("Seeding network with", seed)
280280
}
281+
peers := append(tab.nursery, seeds...)
282+
281283
// Bootstrap the table with a self lookup
282-
all := tab.bondall(append(tab.nursery, seeds...))
283-
tab.mutex.Lock()
284-
tab.add(all)
285-
tab.mutex.Unlock()
286-
tab.Lookup(tab.self.ID)
284+
if len(peers) > 0 {
285+
tab.mutex.Lock()
286+
tab.add(peers)
287+
tab.mutex.Unlock()
288+
289+
tab.Lookup(tab.self.ID)
290+
}
287291
// TODO: the Kademlia paper says that we're supposed to perform
288292
// random lookups in all buckets further away than our closest neighbor.
289293
}

0 commit comments

Comments
 (0)