mirror of
https://github.com/matrix-org/pinecone.git
synced 2026-10-24 11:59:18 +03:00
Check ascending node for boostraps, fall back to root node for locally originated bootstraps
This commit is contained in:
@@ -189,11 +189,24 @@ func (t *virtualSnake) getVirtualSnakeBootstrapNextHop(from *Peer, destKey types
|
||||
bestKey, bestPort = key, port
|
||||
}
|
||||
|
||||
// Check the root key
|
||||
if from.port == 0 || bestKey.EqualTo(destKey) || util.DHTOrdered(bestKey, destKey, rootKey) {
|
||||
// Check the root key, as a last-resort we will use it
|
||||
// to climb up towards the root
|
||||
if from.port == 0 || util.LessThan(bestKey, destKey) {
|
||||
newCandidate(rootKey, rootPort)
|
||||
}
|
||||
|
||||
// Special rules for if the bootstrap originated locally
|
||||
if from.port == 0 {
|
||||
// Check our ascending node, if we have one
|
||||
t.ascendingMutex.RLock()
|
||||
if asc := t.ascending; asc != nil && time.Since(asc.LastSeen) <= virtualSnakeNeighExpiryPeriod {
|
||||
if util.LessThan(destKey, asc.PublicKey) {
|
||||
newCandidate(asc.PublicKey, asc.Port)
|
||||
}
|
||||
}
|
||||
t.ascendingMutex.RUnlock()
|
||||
}
|
||||
|
||||
// Check our direct ancestors between us and the root
|
||||
if len(ancestors) > 0 {
|
||||
for _, ancestorKey := range ancestors[1:] {
|
||||
|
||||
Reference in New Issue
Block a user