From 7eb720e53572b946bc9031151c593c1ca09746fc Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 17 Apr 2019 13:24:32 -0700 Subject: [PATCH] routing: mark policy as stale if edge remains double disabled To ensure we don't mark an edge as live again just because an update with a fresh timestamp was received, we'll ensure that we reject any new updates for zombie channels if they remain disabled when running with AssumeChannelValid. --- routing/router.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/routing/router.go b/routing/router.go index 5e984b8af..b6c70e1ab 100644 --- a/routing/router.go +++ b/routing/router.go @@ -2256,9 +2256,21 @@ func (r *ChannelRouter) IsStaleEdgePolicy(chanID lnwire.ShortChannelID, } - // If we know of the edge as a zombie, then we'll check the timestamp of - // this message to determine whether it's fresh. + // If we know of the edge as a zombie, then we'll make some additional + // checks to determine if the new policy is fresh. if isZombie { + // When running with AssumeChannelValid, we also prune channels + // if both of their edges are disabled. We'll mark the new + // policy as stale if it remains disabled. + if r.cfg.AssumeChannelValid { + isDisabled := flags&lnwire.ChanUpdateDisabled == + lnwire.ChanUpdateDisabled + if isDisabled { + return true + } + } + + // Otherwise, we'll fall back to our usual ChannelPruneExpiry. return time.Since(timestamp) > r.cfg.ChannelPruneExpiry }