mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-02 03:54:26 +02:00
htlcswitch: skip checking replays for reforwarded packets
We now rely on the forwarding package's state to decide whether a given packet is a reforwarding or not. If we know it's a reforwarding packet, there's no need to check for replays in the `sharedHashes` bucket, which behaves the same as if we are querying the `batchReplayBkt`.
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
2b3c04ccaa
commit
cb009119c4
@@ -745,7 +745,8 @@ func (r *DecodeHopIteratorResponse) Result() (Iterator, lnwire.FailCode) {
|
||||
// the presented readers and rhashes *NEVER* deviate across invocations for the
|
||||
// same id.
|
||||
func (p *OnionProcessor) DecodeHopIterators(id []byte,
|
||||
reqs []DecodeHopIteratorRequest) ([]DecodeHopIteratorResponse, error) {
|
||||
reqs []DecodeHopIteratorRequest,
|
||||
reforward bool) ([]DecodeHopIteratorResponse, error) {
|
||||
|
||||
var (
|
||||
batchSize = len(reqs)
|
||||
@@ -864,11 +865,12 @@ func (p *OnionProcessor) DecodeHopIterators(id []byte,
|
||||
continue
|
||||
}
|
||||
|
||||
// If this index is contained in the replay set, mark it with a
|
||||
// temporary channel failure error code. We infer that the
|
||||
// offending error was due to a replayed packet because this
|
||||
// index was found in the replay set.
|
||||
if replays.Contains(uint16(i)) {
|
||||
// If this index is contained in the replay set, and it is not a
|
||||
// reforwarding on startup, mark it with a permanent channel
|
||||
// failure error code. We infer that the offending error was due
|
||||
// to a replayed packet because this index was found in the
|
||||
// replay set.
|
||||
if !reforward && replays.Contains(uint16(i)) {
|
||||
log.Errorf("unable to process onion packet: %v",
|
||||
sphinx.ErrReplayedPacket)
|
||||
|
||||
|
Reference in New Issue
Block a user