htlcswitch: change ForwardPackets to return error
As part of the preparation to the switch interceptor feature, this function is changed to return error instead of error channel that is closed automatically. Returning an error channel has become complex to maintain and implement when adding more asynchronous flows to the switch. The change doesn't affect the current behavior which logs the errors as before.
This commit is contained in:
1 parent
87880c0d56
commit
1a6701122c
6 files changed
+131
-135
No files matched your search
+7
-5
@@ -135,10 +135,10 @@ type ChannelLinkConfig struct {
|
||||
Switch *Switch
|
||||
|
||||
// ForwardPackets attempts to forward the batch of htlcs through the
|
||||
// switch, any failed packets will be returned to the provided
|
||||
// ChannelLink. The link's quit signal should be provided to allow
|
||||
// switch. The function returns and error in case it fails to send one or
|
||||
// more packets. The link's quit signal should be provided to allow
|
||||
// cancellation of forwarding during link shutdown.
|
||||
ForwardPackets func(chan struct{}, ...*htlcPacket) chan error
|
||||
ForwardPackets func(chan struct{}, ...*htlcPacket) error
|
||||
|
||||
// DecodeHopIterators facilitates batched decoding of HTLC Sphinx onion
|
||||
// blobs, which are then used to inform how to forward an HTLC.
|
||||
@@ -2971,8 +2971,10 @@ func (l *channelLink) forwardBatch(packets ...*htlcPacket) {
|
||||
filteredPkts = append(filteredPkts, pkt)
|
||||
}
|
||||
|
||||
errChan := l.cfg.ForwardPackets(l.quit, filteredPkts...)
|
||||
go handleBatchFwdErrs(errChan, l.log)
|
||||
if err := l.cfg.ForwardPackets(l.quit, filteredPkts...); err != nil {
|
||||
log.Errorf("Unhandled error while reforwarding htlc "+
|
||||
"settle/fail over htlcswitch: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// sendHTLCError functions cancels HTLC and send cancel message back to the
|
||||
|
||||
Reference in new issue
Block a user