mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
move special peer/dht insert logic form router.go to dht.go
This commit is contained in:
parent
e65910806c
commit
dfcdafa55c
2 changed files with 10 additions and 6 deletions
|
@ -134,6 +134,15 @@ func (t *dht) insert(info *dhtInfo) {
|
|||
t.table[*info.getNodeID()] = info
|
||||
}
|
||||
|
||||
// Insert a peer into the table if it hasn't been pinged lately, to keep peers from dropping
|
||||
func (t *dht) insertPeer(info *dhtInfo) {
|
||||
oldInfo, isIn := t.table[*info.getNodeID()]
|
||||
if !isIn || time.Since(oldInfo.recv) > 45*time.Second {
|
||||
// TODO? also check coords?
|
||||
t.insert(info)
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if first/second/third are (partially) ordered correctly.
|
||||
func dht_ordered(first, second, third *crypto.NodeID) bool {
|
||||
lessOrEqual := func(first, second *crypto.NodeID) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue