mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-23 00:51:35 +00:00
remove maintenance searches and throttle logic, to focus on debugging in this simpler case first
This commit is contained in:
parent
3dbffae99f
commit
8825494d59
@ -13,9 +13,7 @@ type dhtInfo struct {
|
|||||||
nodeID_hidden *NodeID
|
nodeID_hidden *NodeID
|
||||||
key boxPubKey
|
key boxPubKey
|
||||||
coords []byte
|
coords []byte
|
||||||
send time.Time // When we last sent a message
|
|
||||||
recv time.Time // When we last received a message
|
recv time.Time // When we last received a message
|
||||||
throttle time.Duration
|
|
||||||
pings int // Time out if at least 3 consecutive maintenance pings drop
|
pings int // Time out if at least 3 consecutive maintenance pings drop
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,16 +123,6 @@ func (t *dht) insert(info *dhtInfo) {
|
|||||||
panic("FIXME")
|
panic("FIXME")
|
||||||
}
|
}
|
||||||
info.recv = time.Now()
|
info.recv = time.Now()
|
||||||
if oldInfo, isIn := t.table[*info.getNodeID()]; isIn {
|
|
||||||
info.send = oldInfo.send
|
|
||||||
info.throttle = oldInfo.throttle
|
|
||||||
} else {
|
|
||||||
info.send = info.recv
|
|
||||||
}
|
|
||||||
info.throttle += time.Second
|
|
||||||
if info.throttle > 30*time.Second {
|
|
||||||
info.throttle = 30 * time.Second
|
|
||||||
}
|
|
||||||
t.table[*info.getNodeID()] = info
|
t.table[*info.getNodeID()] = info
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +167,6 @@ func (t *dht) handleReq(req *dhtReq) {
|
|||||||
}
|
}
|
||||||
// For bootstrapping to work, we need to add these nodes to the table
|
// For bootstrapping to work, we need to add these nodes to the table
|
||||||
t.insert(&info)
|
t.insert(&info)
|
||||||
info.send = info.send.Add(-time.Minute)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends a lookup response to the specified node.
|
// Sends a lookup response to the specified node.
|
||||||
@ -308,7 +295,6 @@ func (t *dht) ping(info *dhtInfo, target *NodeID) {
|
|||||||
Coords: coords,
|
Coords: coords,
|
||||||
Dest: *target,
|
Dest: *target,
|
||||||
}
|
}
|
||||||
info.send = time.Now()
|
|
||||||
t.sendReq(&req, info)
|
t.sendReq(&req, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,39 +309,8 @@ func (t *dht) doMaintenance() {
|
|||||||
successor = info
|
successor = info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if successor != nil &&
|
if successor != nil {
|
||||||
now.Sub(successor.recv) > successor.throttle &&
|
|
||||||
now.Sub(successor.send) > 3*time.Second {
|
|
||||||
t.ping(successor, nil)
|
t.ping(successor, nil)
|
||||||
successor.pings++
|
successor.pings++
|
||||||
if now.Sub(t.search) > time.Minute {
|
|
||||||
// Start a search for our successor, beginning at this node's parent
|
|
||||||
// This should (hopefully) help bootstrap
|
|
||||||
t.core.switchTable.mutex.RLock()
|
|
||||||
parentPort := t.core.switchTable.parent
|
|
||||||
t.core.switchTable.mutex.RUnlock()
|
|
||||||
ports := t.core.peers.getPorts()
|
|
||||||
if parent, isIn := ports[parentPort]; isIn {
|
|
||||||
t.search = now
|
|
||||||
target := successor.getNodeID().prev()
|
|
||||||
sinfo, isIn := t.core.searches.searches[target]
|
|
||||||
if !isIn {
|
|
||||||
var mask NodeID
|
|
||||||
for idx := range mask {
|
|
||||||
mask[idx] = 0xff
|
|
||||||
}
|
|
||||||
sinfo = t.core.searches.newIterSearch(&target, &mask)
|
|
||||||
toVisit := sinfo.toVisit
|
|
||||||
parentNodeID := getNodeID(&parent.box)
|
|
||||||
for _, ninfo := range toVisit {
|
|
||||||
if *ninfo.getNodeID() == *parentNodeID {
|
|
||||||
toVisit = append(toVisit, ninfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sinfo.toVisit = toVisit
|
|
||||||
}
|
|
||||||
t.core.searches.continueSearch(sinfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user