routing: modify applyChannelUpdate to not error out if update is stale

In this commit we fix a slight bug within the existing SendPayment loop
which would cause the wrong error to be returned to users. Prior to
this commit, if we received an update identical to what we were already
aware of, then that error would be returned rather than the
ForwardingError that encapsulated this update.

In this commit with remedy this by properly returning the exact error.

Partially fixes #391.
This commit is contained in:
Olaoluwa Osuntokun 2017-10-24 18:22:58 -07:00
parent 3e64ba0394
commit 176fde4ec0
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

View File

@ -805,7 +805,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
case 0:
if edge1Timestamp.After(msg.LastUpdate) ||
edge1Timestamp.Equal(msg.LastUpdate) {
return newErrf(ErrIgnored, "Ignoring announcement "+
return newErrf(ErrIgnored, "Ignoring update "+
"(flags=%v) for known chan_id=%v", msg.Flags,
msg.ChannelID)
@ -817,7 +817,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
if edge2Timestamp.After(msg.LastUpdate) ||
edge2Timestamp.Equal(msg.LastUpdate) {
return newErrf(ErrIgnored, "Ignoring announcement "+
return newErrf(ErrIgnored, "Ignoring update "+
"(flags=%v) for known chan_id=%v", msg.Flags,
msg.ChannelID)
}
@ -1477,7 +1477,7 @@ func (r *ChannelRouter) applyChannelUpdate(msg *lnwire.ChannelUpdate) error {
FeeBaseMSat: lnwire.MilliSatoshi(msg.BaseFee),
FeeProportionalMillionths: lnwire.MilliSatoshi(msg.FeeRate),
})
if err != nil {
if err != nil && !IsError(err, ErrIgnored) {
return fmt.Errorf("Unable to apply channel update: %v", err)
}