mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 19:10:59 +02:00
routing/router: prune zombies when either end is stale
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
672dbe39e7
commit
e3a8b3b0c4
@ -824,30 +824,23 @@ func (r *ChannelRouter) pruneZombieChans() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If *both* edges haven't been updated for a period of
|
// If either edge hasn't been updated for a period of
|
||||||
// chanExpiry, then we'll mark the channel itself as eligible
|
// chanExpiry, then we'll mark the channel itself as eligible
|
||||||
// for graph pruning.
|
// for graph pruning.
|
||||||
var e1Zombie, e2Zombie bool
|
e1Zombie := e1 == nil || time.Since(e1.LastUpdate) >= chanExpiry
|
||||||
if e1 != nil {
|
e2Zombie := e2 == nil || time.Since(e2.LastUpdate) >= chanExpiry
|
||||||
e1Zombie = time.Since(e1.LastUpdate) >= chanExpiry
|
|
||||||
if e1Zombie {
|
if e1Zombie {
|
||||||
log.Tracef("Edge #1 of ChannelID(%v) last "+
|
log.Tracef("Node1 pubkey=%x of chan_id=%v is zombie",
|
||||||
"update: %v", info.ChannelID,
|
info.NodeKey1Bytes, info.ChannelID)
|
||||||
e1.LastUpdate)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if e2 != nil {
|
if e2Zombie {
|
||||||
e2Zombie = time.Since(e2.LastUpdate) >= chanExpiry
|
log.Tracef("Node2 pubkey=%x of chan_id=%v is zombie",
|
||||||
if e2Zombie {
|
info.NodeKey2Bytes, info.ChannelID)
|
||||||
log.Tracef("Edge #2 of ChannelID(%v) last "+
|
|
||||||
"update: %v", info.ChannelID,
|
|
||||||
e2.LastUpdate)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the channel is not considered zombie, we can move on to
|
// Return early if both sides have a recent update.
|
||||||
// the next.
|
if !e1Zombie && !e2Zombie {
|
||||||
if !e1Zombie || !e2Zombie {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user