reverse dht ownership order from predecessor to successor, this plays nicer with the default 0 bits in unknown node IDs

This commit is contained in:
Arceliar 2018-10-21 18:15:04 -05:00
parent 5e3959f1d0
commit 253861ebd3
2 changed files with 11 additions and 35 deletions

View file

@ -113,11 +113,12 @@ func (s *searches) addToSearch(sinfo *searchInfo, res *dhtRes) {
sort.SliceStable(sinfo.toVisit, func(i, j int) bool {
// Should return true if i is closer to the destination than j
// FIXME for some reason it works better backwards, why?!
return dht_ordered(sinfo.toVisit[j].getNodeID(), sinfo.toVisit[i].getNodeID(), &res.Dest)
//return dht_ordered(sinfo.toVisit[j].getNodeID(), sinfo.toVisit[i].getNodeID(), &res.Dest)
return dht_ordered(&res.Dest, sinfo.toVisit[i].getNodeID(), sinfo.toVisit[j].getNodeID())
})
// Truncate to some maximum size
if len(sinfo.toVisit) > search_MAX_SEARCH_SIZE {
//sinfo.toVisit = sinfo.toVisit[:search_MAX_SEARCH_SIZE]
sinfo.toVisit = sinfo.toVisit[:search_MAX_SEARCH_SIZE]
}
}