mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-12-19 20:25:51 +01:00
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:
@@ -86,7 +86,7 @@ type mailBoxConfig struct {
|
||||
// forwardPackets send a varidic number of htlcPackets to the switch to
|
||||
// be routed. A quit channel should be provided so that the call can
|
||||
// properly exit during shutdown.
|
||||
forwardPackets func(chan struct{}, ...*htlcPacket) chan error
|
||||
forwardPackets func(chan struct{}, ...*htlcPacket) error
|
||||
|
||||
// clock is a time source for the mailbox.
|
||||
clock clock.Clock
|
||||
@@ -680,8 +680,10 @@ func (m *memoryMailBox) FailAdd(pkt *htlcPacket) {
|
||||
},
|
||||
}
|
||||
|
||||
errChan := m.cfg.forwardPackets(m.quit, failPkt)
|
||||
go handleBatchFwdErrs(errChan, log)
|
||||
if err := m.cfg.forwardPackets(m.quit, failPkt); err != nil {
|
||||
log.Errorf("Unhandled error while reforwarding packets "+
|
||||
"settle/fail over htlcswitch: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// MessageOutBox returns a channel that any new messages ready for delivery
|
||||
@@ -734,7 +736,7 @@ type mailOrchConfig struct {
|
||||
// forwardPackets send a varidic number of htlcPackets to the switch to
|
||||
// be routed. A quit channel should be provided so that the call can
|
||||
// properly exit during shutdown.
|
||||
forwardPackets func(chan struct{}, ...*htlcPacket) chan error
|
||||
forwardPackets func(chan struct{}, ...*htlcPacket) error
|
||||
|
||||
// fetchUpdate retreives the most recent channel update for the channel
|
||||
// this mailbox belongs to.
|
||||
|
||||
Reference in New Issue
Block a user