mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-22 23:41:35 +00:00
more testing
This commit is contained in:
parent
bcbd24120d
commit
f0bd40ff68
@ -102,12 +102,22 @@ func (t *dht) reset() {
|
|||||||
// Does a DHT lookup and returns up to dht_lookup_size results
|
// Does a DHT lookup and returns up to dht_lookup_size results
|
||||||
// If allowWorse = true, begins with best know predecessor for ID and works backwards, even if these nodes are worse predecessors than we are, to be used when intializing searches
|
// If allowWorse = true, begins with best know predecessor for ID and works backwards, even if these nodes are worse predecessors than we are, to be used when intializing searches
|
||||||
// If allowWorse = false, begins with the best known successor for ID and works backwards (next is predecessor, etc, inclusive of the ID if it's a known node)
|
// If allowWorse = false, begins with the best known successor for ID and works backwards (next is predecessor, etc, inclusive of the ID if it's a known node)
|
||||||
func (t *dht) lookup(nodeID *NodeID, allowWorse bool) []*dhtInfo {
|
func (t *dht) lookup(nodeID *NodeID, everything bool) []*dhtInfo {
|
||||||
|
var results []*dhtInfo
|
||||||
|
for infoID, info := range t.table {
|
||||||
|
if everything || t.isImportant(&infoID) {
|
||||||
|
results = append(results, info)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *dht) old_lookup(nodeID *NodeID, allowWorse bool) []*dhtInfo {
|
||||||
var results []*dhtInfo
|
var results []*dhtInfo
|
||||||
var successor *dhtInfo
|
var successor *dhtInfo
|
||||||
sTarget := t.nodeID.next()
|
sTarget := t.nodeID.next()
|
||||||
for infoID, info := range t.table {
|
for infoID, info := range t.table {
|
||||||
if allowWorse || dht_ordered(&t.nodeID, &infoID, nodeID) {
|
if true || allowWorse || dht_ordered(&t.nodeID, &infoID, nodeID) {
|
||||||
results = append(results, info)
|
results = append(results, info)
|
||||||
} else {
|
} else {
|
||||||
if successor == nil || dht_ordered(&sTarget, &infoID, successor.getNodeID()) {
|
if successor == nil || dht_ordered(&sTarget, &infoID, successor.getNodeID()) {
|
||||||
@ -122,7 +132,7 @@ func (t *dht) lookup(nodeID *NodeID, allowWorse bool) []*dhtInfo {
|
|||||||
results = append([]*dhtInfo{successor}, results...)
|
results = append([]*dhtInfo{successor}, results...)
|
||||||
}
|
}
|
||||||
if len(results) > dht_lookup_size {
|
if len(results) > dht_lookup_size {
|
||||||
results = results[:dht_lookup_size]
|
//results = results[:dht_lookup_size] //FIXME debug
|
||||||
}
|
}
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
@ -265,7 +275,7 @@ func (t *dht) handleRes(res *dhtRes) {
|
|||||||
}
|
}
|
||||||
t.insert(&rinfo) // Or at the end, after checking successor/predecessor?
|
t.insert(&rinfo) // Or at the end, after checking successor/predecessor?
|
||||||
if len(res.Infos) > dht_lookup_size {
|
if len(res.Infos) > dht_lookup_size {
|
||||||
res.Infos = res.Infos[:dht_lookup_size]
|
//res.Infos = res.Infos[:dht_lookup_size] //FIXME debug
|
||||||
}
|
}
|
||||||
for _, info := range res.Infos {
|
for _, info := range res.Infos {
|
||||||
if *info.getNodeID() == t.nodeID {
|
if *info.getNodeID() == t.nodeID {
|
||||||
|
Loading…
Reference in New Issue
Block a user