mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 15:40:59 +02:00
htlcswitch: concurrent onion decoding
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
@@ -293,12 +294,21 @@ func (p *OnionProcessor) DecodeHopIterators(id []byte,
|
||||
}
|
||||
}
|
||||
|
||||
for i, req := range reqs {
|
||||
onionPkt := &onionPkts[i]
|
||||
resp := &resps[i]
|
||||
// Execute cpu-heavy onion decoding in parallel.
|
||||
var wg sync.WaitGroup
|
||||
for i := range reqs {
|
||||
wg.Add(1)
|
||||
go func(seqNum uint16) {
|
||||
defer wg.Done()
|
||||
|
||||
resp.FailCode = decode(uint16(i), onionPkt, req)
|
||||
onionPkt := &onionPkts[seqNum]
|
||||
|
||||
resps[seqNum].FailCode = decode(
|
||||
seqNum, onionPkt, reqs[seqNum],
|
||||
)
|
||||
}(uint16(i))
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
// With that batch created, we will now attempt to write the shared
|
||||
// secrets to disk. This operation will returns the set of indices that
|
||||
|
Reference in New Issue
Block a user