swarm: fix swarm index out of range (#14843)

* swarm: skip empty nodes when in findBest
This commit is contained in:
ezioruan 2018-01-28 14:45:27 +08:00
parent 722bac84fa
commit c910b7c28e

View file

@ -204,6 +204,12 @@ func (self *KadDb) findBest(maxBinSize int, binSize func(int) int) (node *NodeRe
count++
node = dbrow[cursor]
// skip empty nodes
if node == nil {
log.Debug(fmt.Sprintf("kaddb record (PO%03d:%d/%d) not found", po, cursor, len(dbrow)))
continue ROW
}
// skip already connected nodes
if node.node != nil {
log.Debug(fmt.Sprintf("kaddb record %v (PO%03d:%d/%d) already connected", node.Addr, po, cursor, len(dbrow)))