htlcswitch: make handleBatchFwdErrors a pure function
This commit is contained in:
parent
f3051efeb3
commit
12bbf28e65
@ -2948,27 +2948,7 @@ func (l *channelLink) forwardBatch(packets ...*htlcPacket) {
|
||||
}
|
||||
|
||||
errChan := l.cfg.ForwardPackets(l.quit, filteredPkts...)
|
||||
go l.handleBatchFwdErrs(errChan)
|
||||
}
|
||||
|
||||
// handleBatchFwdErrs waits on the given errChan until it is closed, logging
|
||||
// the errors returned from any unsuccessful forwarding attempts.
|
||||
func (l *channelLink) handleBatchFwdErrs(errChan chan error) {
|
||||
for {
|
||||
err, ok := <-errChan
|
||||
if !ok {
|
||||
// Err chan has been drained or switch is shutting
|
||||
// down. Either way, return.
|
||||
return
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
l.log.Errorf("unhandled error while forwarding htlc packet over "+
|
||||
"htlcswitch: %v", err)
|
||||
}
|
||||
go handleBatchFwdErrs(errChan, l.log)
|
||||
}
|
||||
|
||||
// sendHTLCError functions cancels HTLC and send cancel message back to the
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btclog"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
@ -1972,13 +1973,13 @@ func (s *Switch) reforwardSettleFails(fwdPkgs []*channeldb.FwdPkg) {
|
||||
// link quit channel, meaning the send will fail only if the
|
||||
// switch receives a shutdown request.
|
||||
errChan := s.ForwardPackets(nil, switchPackets...)
|
||||
go handleBatchFwdErrs(errChan)
|
||||
go handleBatchFwdErrs(errChan, log)
|
||||
}
|
||||
}
|
||||
|
||||
// handleBatchFwdErrs waits on the given errChan until it is closed, logging the
|
||||
// errors returned from any unsuccessful forwarding attempts.
|
||||
func handleBatchFwdErrs(errChan chan error) {
|
||||
func handleBatchFwdErrs(errChan chan error, l btclog.Logger) {
|
||||
for {
|
||||
err, ok := <-errChan
|
||||
if !ok {
|
||||
@ -1991,7 +1992,7 @@ func handleBatchFwdErrs(errChan chan error) {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Errorf("unhandled error while reforwarding htlc "+
|
||||
l.Errorf("Unhandled error while reforwarding htlc "+
|
||||
"settle/fail over htlcswitch: %v", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user