mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
fix kademlia table lookup when max prox bin is empty include next bucket
This commit is contained in:
parent
4a438dc233
commit
4a7f5c9899
2 changed files with 4 additions and 4 deletions
|
|
@ -198,8 +198,8 @@ func (self *NetStore) addRetrieveRequest(req *retrieveRequestMsgData) {
|
|||
// it's assumed that caller holds the lock
|
||||
func (self *NetStore) startSearch(chunk *Chunk, id int64, timeout *time.Time) {
|
||||
chunk.req.status = reqSearching
|
||||
dpaLogger.Debugf("NetStore.startSearch: %064x - getting peers from KΛÐΞMLIΛ...", chunk.Key)
|
||||
peers := self.hive.getPeers(chunk.Key, 0)
|
||||
dpaLogger.Debugf("NetStore.startSearch: %064x - received %d peers from KΛÐΞMLIΛ...", chunk.Key, len(peers))
|
||||
req := &retrieveRequestMsgData{
|
||||
Key: chunk.Key,
|
||||
Id: uint64(id),
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ func (self *Kademlia) getNodes(target Address, max int) (r nodesByDistance) {
|
|||
start := index
|
||||
var down bool
|
||||
if index >= self.proxLimit {
|
||||
index = self.proxLimit
|
||||
start = self.MaxProx
|
||||
down = true
|
||||
}
|
||||
|
|
@ -266,8 +267,8 @@ func (self *Kademlia) getNodes(target Address, max int) (r nodesByDistance) {
|
|||
r.push(bucket[i], limit)
|
||||
n++
|
||||
}
|
||||
if max == 0 && start == index ||
|
||||
max > 0 && down && start <= index && (n >= max || n == self.Count() || start == 0) {
|
||||
if max == 0 && start <= index && n > 0 ||
|
||||
max > 0 && down && start <= index && (n >= limit || n == self.Count() || start == 0) {
|
||||
break
|
||||
}
|
||||
if down {
|
||||
|
|
@ -453,7 +454,6 @@ bit first).
|
|||
proximity(x, y) counts the common zeros in the front of this distance measure.
|
||||
*/
|
||||
func proximity(one, other Address) (ret int) {
|
||||
fmt.Printf("%08b ^ %08b = %08b\n", one[0], other[0], one[0]^other[0])
|
||||
for i := 0; i < len(one); i++ {
|
||||
oxo := one[i] ^ other[i]
|
||||
for j := 0; j < 8; j++ {
|
||||
|
|
|
|||
Loading…
Reference in a new issue