channeldb/forwarding_package: loosen Add/SettleFailRef acking
This commit loosens the fwdpkg reference acking to be more tolerant of prior deletions. Specifically, we won't fail if certain channels are not found or fwdpkgs do not exist. This will make us more tolerant to future changes where we: - remove fwdpkgs on channel close - defensively cleanup stray responses
This commit is contained in:
parent
6c903393e5
commit
215a47e6bf
@ -3,11 +3,11 @@ package channeldb
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/coreos/bbolt"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
)
|
||||
|
||||
@ -759,7 +759,11 @@ func ackAddHtlcsAtHeight(sourceBkt *bolt.Bucket, height uint64,
|
||||
heightKey := makeLogKey(height)
|
||||
heightBkt := sourceBkt.Bucket(heightKey[:])
|
||||
if heightBkt == nil {
|
||||
return ErrCorruptedFwdPkg
|
||||
// If the height bucket isn't found, this could be because the
|
||||
// forwarding package was already removed. We'll return nil to
|
||||
// signal that the operation is successful, as there is nothing
|
||||
// to ack.
|
||||
return nil
|
||||
}
|
||||
|
||||
// Load ack filter from disk.
|
||||
@ -830,6 +834,11 @@ func ackSettleFails(tx *bolt.Tx, settleFailRefs []SettleFailRef) error {
|
||||
destKey := makeLogKey(dest.ToUint64())
|
||||
destBkt := fwdPkgBkt.Bucket(destKey[:])
|
||||
if destBkt == nil {
|
||||
// If the destination bucket is not found, this is
|
||||
// likely the result of the destination channel being
|
||||
// closed and having it's forwarding packages wiped. We
|
||||
// won't treat this as an error, because the response
|
||||
// will no longer be retransmitted internally.
|
||||
continue
|
||||
}
|
||||
|
||||
@ -852,6 +861,9 @@ func ackSettleFailsAtHeight(destBkt *bolt.Bucket, height uint64,
|
||||
heightKey := makeLogKey(height)
|
||||
heightBkt := destBkt.Bucket(heightKey[:])
|
||||
if heightBkt == nil {
|
||||
// If the height bucket isn't found, this could be because the
|
||||
// forwarding package was already removed. We'll return nil to
|
||||
// signal that the operation is as there is nothing to ack.
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user