From 4b04e1afd1e4b9c80a67a9eb712e30d079c1b2b8 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 20 Aug 2018 14:28:10 +0200 Subject: [PATCH] routing: return ErrRejected if found in reject cache We make sure to return an error other than ErrIgnored, as ErrIgnored is expected to only be returned for updates where we already have the necessary information in the database. In case of a channel ID found in the rejectCache, there was a possibility that we had rejected an invalid update for this channel earlier, and when attempting to add the current update we wouldn't distinguish the failure to add from an outdated/ignored update. --- routing/errors.go | 5 +++++ routing/router.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/routing/errors.go b/routing/errors.go index 1867b110..0eb6cb37 100644 --- a/routing/errors.go +++ b/routing/errors.go @@ -39,6 +39,11 @@ const ( // announcement was given for node not found in any channel. ErrIgnored + // ErrRejected is returned if the update is for a channel ID that was + // previously added to the reject cache because of an invalid update + // was attempted to be processed. + ErrRejected + // ErrPaymentAttemptTimeout is an error that indicates that a payment // attempt timed out before we were able to successfully route an HTLC. ErrPaymentAttemptTimeout diff --git a/routing/router.go b/routing/router.go index b202ac7b..e275843a 100644 --- a/routing/router.go +++ b/routing/router.go @@ -946,7 +946,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error { r.rejectMtx.RLock() if _, ok := r.rejectCache[msg.ChannelID]; ok { r.rejectMtx.RUnlock() - return newErrf(ErrIgnored, "recently rejected "+ + return newErrf(ErrRejected, "recently rejected "+ "chan_id=%v", msg.ChannelID) } r.rejectMtx.RUnlock() @@ -1055,7 +1055,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error { r.rejectMtx.RLock() if _, ok := r.rejectCache[msg.ChannelID]; ok { r.rejectMtx.RUnlock() - return newErrf(ErrIgnored, "recently rejected "+ + return newErrf(ErrRejected, "recently rejected "+ "chan_id=%v", msg.ChannelID) } r.rejectMtx.RUnlock()