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.
This commit is contained in:
Johan T. Halseth 2018-08-20 14:28:10 +02:00
parent c56082006f
commit 4b04e1afd1
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 7 additions and 2 deletions

@ -39,6 +39,11 @@ const (
// announcement was given for node not found in any channel. // announcement was given for node not found in any channel.
ErrIgnored 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 // ErrPaymentAttemptTimeout is an error that indicates that a payment
// attempt timed out before we were able to successfully route an HTLC. // attempt timed out before we were able to successfully route an HTLC.
ErrPaymentAttemptTimeout ErrPaymentAttemptTimeout

@ -946,7 +946,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
r.rejectMtx.RLock() r.rejectMtx.RLock()
if _, ok := r.rejectCache[msg.ChannelID]; ok { if _, ok := r.rejectCache[msg.ChannelID]; ok {
r.rejectMtx.RUnlock() r.rejectMtx.RUnlock()
return newErrf(ErrIgnored, "recently rejected "+ return newErrf(ErrRejected, "recently rejected "+
"chan_id=%v", msg.ChannelID) "chan_id=%v", msg.ChannelID)
} }
r.rejectMtx.RUnlock() r.rejectMtx.RUnlock()
@ -1055,7 +1055,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
r.rejectMtx.RLock() r.rejectMtx.RLock()
if _, ok := r.rejectCache[msg.ChannelID]; ok { if _, ok := r.rejectCache[msg.ChannelID]; ok {
r.rejectMtx.RUnlock() r.rejectMtx.RUnlock()
return newErrf(ErrIgnored, "recently rejected "+ return newErrf(ErrRejected, "recently rejected "+
"chan_id=%v", msg.ChannelID) "chan_id=%v", msg.ChannelID)
} }
r.rejectMtx.RUnlock() r.rejectMtx.RUnlock()