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
|
// it's assumed that caller holds the lock
|
||||||
func (self *NetStore) startSearch(chunk *Chunk, id int64, timeout *time.Time) {
|
func (self *NetStore) startSearch(chunk *Chunk, id int64, timeout *time.Time) {
|
||||||
chunk.req.status = reqSearching
|
chunk.req.status = reqSearching
|
||||||
dpaLogger.Debugf("NetStore.startSearch: %064x - getting peers from KΛÐΞMLIΛ...", chunk.Key)
|
|
||||||
peers := self.hive.getPeers(chunk.Key, 0)
|
peers := self.hive.getPeers(chunk.Key, 0)
|
||||||
|
dpaLogger.Debugf("NetStore.startSearch: %064x - received %d peers from KΛÐΞMLIΛ...", chunk.Key, len(peers))
|
||||||
req := &retrieveRequestMsgData{
|
req := &retrieveRequestMsgData{
|
||||||
Key: chunk.Key,
|
Key: chunk.Key,
|
||||||
Id: uint64(id),
|
Id: uint64(id),
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,7 @@ func (self *Kademlia) getNodes(target Address, max int) (r nodesByDistance) {
|
||||||
start := index
|
start := index
|
||||||
var down bool
|
var down bool
|
||||||
if index >= self.proxLimit {
|
if index >= self.proxLimit {
|
||||||
|
index = self.proxLimit
|
||||||
start = self.MaxProx
|
start = self.MaxProx
|
||||||
down = true
|
down = true
|
||||||
}
|
}
|
||||||
|
|
@ -266,8 +267,8 @@ func (self *Kademlia) getNodes(target Address, max int) (r nodesByDistance) {
|
||||||
r.push(bucket[i], limit)
|
r.push(bucket[i], limit)
|
||||||
n++
|
n++
|
||||||
}
|
}
|
||||||
if max == 0 && start == index ||
|
if max == 0 && start <= index && n > 0 ||
|
||||||
max > 0 && down && start <= index && (n >= max || n == self.Count() || start == 0) {
|
max > 0 && down && start <= index && (n >= limit || n == self.Count() || start == 0) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if down {
|
if down {
|
||||||
|
|
@ -453,7 +454,6 @@ bit first).
|
||||||
proximity(x, y) counts the common zeros in the front of this distance measure.
|
proximity(x, y) counts the common zeros in the front of this distance measure.
|
||||||
*/
|
*/
|
||||||
func proximity(one, other Address) (ret int) {
|
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++ {
|
for i := 0; i < len(one); i++ {
|
||||||
oxo := one[i] ^ other[i]
|
oxo := one[i] ^ other[i]
|
||||||
for j := 0; j < 8; j++ {
|
for j := 0; j < 8; j++ {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue