@@ -3,6 +3,7 @@ package htlcswitch
3
3
import (
4
4
"bytes"
5
5
"container/list"
6
+ "context"
6
7
"errors"
7
8
"fmt"
8
9
"sync"
@@ -95,7 +96,8 @@ type mailBoxConfig struct {
95
96
// forwardPackets send a varidic number of htlcPackets to the switch to
96
97
// be routed. A quit channel should be provided so that the call can
97
98
// properly exit during shutdown.
98
- forwardPackets func (<- chan struct {}, ... * htlcPacket ) error
99
+ forwardPackets func (context.Context , <- chan struct {},
100
+ ... * htlcPacket ) error
99
101
100
102
// clock is a time source for the mailbox.
101
103
clock clock.Clock
@@ -107,7 +109,7 @@ type mailBoxConfig struct {
107
109
108
110
// failMailboxUpdate is used to fail an expired HTLC and use the
109
111
// correct SCID if the underlying channel uses aliases.
110
- failMailboxUpdate func (outScid ,
112
+ failMailboxUpdate func (ctx context. Context , outScid ,
111
113
mailboxScid lnwire.ShortChannelID ) lnwire.FailureMessage
112
114
}
113
115
@@ -687,6 +689,8 @@ func (m *memoryMailBox) DustPackets() (lnwire.MilliSatoshi,
687
689
// generated LinkError will show an OutgoingFailureDownstreamHtlcAdd
688
690
// FailureDetail.
689
691
func (m * memoryMailBox ) FailAdd (pkt * htlcPacket ) {
692
+ ctx := context .TODO ()
693
+
690
694
// First, remove the packet from mailbox. If we didn't find the packet
691
695
// because it has already been acked, we'll exit early to avoid sending
692
696
// a duplicate fail message through the switch.
@@ -703,7 +707,7 @@ func (m *memoryMailBox) FailAdd(pkt *htlcPacket) {
703
707
// peer if this is a forward, or report to the user if the failed
704
708
// payment was locally initiated.
705
709
failure := m .cfg .failMailboxUpdate (
706
- pkt .originalOutgoingChanID , m .cfg .shortChanID ,
710
+ ctx , pkt .originalOutgoingChanID , m .cfg .shortChanID ,
707
711
)
708
712
709
713
// If the payment was locally initiated (which is indicated by a nil
@@ -748,7 +752,7 @@ func (m *memoryMailBox) FailAdd(pkt *htlcPacket) {
748
752
},
749
753
}
750
754
751
- if err := m .cfg .forwardPackets (m .quit , failPkt ); err != nil {
755
+ if err := m .cfg .forwardPackets (ctx , m .quit , failPkt ); err != nil {
752
756
log .Errorf ("Unhandled error while reforwarding packets " +
753
757
"settle/fail over htlcswitch: %v" , err )
754
758
}
@@ -804,7 +808,8 @@ type mailOrchConfig struct {
804
808
// forwardPackets send a varidic number of htlcPackets to the switch to
805
809
// be routed. A quit channel should be provided so that the call can
806
810
// properly exit during shutdown.
807
- forwardPackets func (<- chan struct {}, ... * htlcPacket ) error
811
+ forwardPackets func (context.Context , <- chan struct {},
812
+ ... * htlcPacket ) error
808
813
809
814
// clock is a time source for the generated mailboxes.
810
815
clock clock.Clock
@@ -816,7 +821,7 @@ type mailOrchConfig struct {
816
821
817
822
// failMailboxUpdate is used to fail an expired HTLC and use the
818
823
// correct SCID if the underlying channel uses aliases.
819
- failMailboxUpdate func (outScid ,
824
+ failMailboxUpdate func (ctx context. Context , outScid ,
820
825
mailboxScid lnwire.ShortChannelID ) lnwire.FailureMessage
821
826
}
822
827
0 commit comments