From e3a8b3b0c447e48cf57f738c6022cfddc2336f90 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Thu, 19 Dec 2019 18:10:02 -0800 Subject: [PATCH] routing/router: prune zombies when either end is stale --- routing/router.go | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/routing/router.go b/routing/router.go index 243bde49..25ce4994 100644 --- a/routing/router.go +++ b/routing/router.go @@ -824,30 +824,23 @@ func (r *ChannelRouter) pruneZombieChans() error { 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 // for graph pruning. - var e1Zombie, e2Zombie bool - if e1 != nil { - e1Zombie = time.Since(e1.LastUpdate) >= chanExpiry - if e1Zombie { - log.Tracef("Edge #1 of ChannelID(%v) last "+ - "update: %v", info.ChannelID, - e1.LastUpdate) - } + e1Zombie := e1 == nil || time.Since(e1.LastUpdate) >= chanExpiry + e2Zombie := e2 == nil || time.Since(e2.LastUpdate) >= chanExpiry + + if e1Zombie { + log.Tracef("Node1 pubkey=%x of chan_id=%v is zombie", + info.NodeKey1Bytes, info.ChannelID) } - if e2 != nil { - e2Zombie = time.Since(e2.LastUpdate) >= chanExpiry - if e2Zombie { - log.Tracef("Edge #2 of ChannelID(%v) last "+ - "update: %v", info.ChannelID, - e2.LastUpdate) - } + if e2Zombie { + log.Tracef("Node2 pubkey=%x of chan_id=%v is zombie", + info.NodeKey2Bytes, info.ChannelID) } - // If the channel is not considered zombie, we can move on to - // the next. - if !e1Zombie || !e2Zombie { + // Return early if both sides have a recent update. + if !e1Zombie && !e2Zombie { return nil }