htlcswitch: pass quit chans as unidirectional
This is a requirement for replacing the quit channel with a Context. The Done() channel of a Context is always recv-only, so all users of that channel must not expect a bidirectional channel.
This commit is contained in:
1 parent
48567e8944
commit
cd14c52ecd
7 files changed
+45
-33
No files matched your search
+24
-16
@@ -2197,17 +2197,21 @@ func newSingleLinkTestHarness(t *testing.T, chanAmt,
|
||||
return nil
|
||||
}
|
||||
|
||||
forwardPackets := func(linkQuit <-chan struct{}, _ bool,
|
||||
packets ...*htlcPacket) error {
|
||||
|
||||
return aliceSwitch.ForwardPackets(linkQuit, packets...)
|
||||
}
|
||||
|
||||
// Instantiate with a long interval, so that we can precisely control
|
||||
// the firing via force feeding.
|
||||
bticker := ticker.NewForce(time.Hour)
|
||||
aliceCfg := ChannelLinkConfig{
|
||||
FwrdingPolicy: globalPolicy,
|
||||
Peer: alicePeer,
|
||||
BestHeight: aliceSwitch.BestHeight,
|
||||
Circuits: aliceSwitch.CircuitModifier(),
|
||||
ForwardPackets: func(linkQuit chan struct{}, _ bool, packets ...*htlcPacket) error {
|
||||
return aliceSwitch.ForwardPackets(linkQuit, packets...)
|
||||
},
|
||||
FwrdingPolicy: globalPolicy,
|
||||
Peer: alicePeer,
|
||||
BestHeight: aliceSwitch.BestHeight,
|
||||
Circuits: aliceSwitch.CircuitModifier(),
|
||||
ForwardPackets: forwardPackets,
|
||||
DecodeHopIterators: decoder.DecodeHopIterators,
|
||||
ExtractErrorEncrypter: func(*btcec.PublicKey) (
|
||||
hop.ErrorEncrypter, lnwire.FailCode) {
|
||||
@@ -4867,17 +4871,21 @@ func (h *persistentLinkHarness) restartLink(
|
||||
return nil
|
||||
}
|
||||
|
||||
forwardPackets := func(linkQuit <-chan struct{}, _ bool,
|
||||
packets ...*htlcPacket) error {
|
||||
|
||||
return h.hSwitch.ForwardPackets(linkQuit, packets...)
|
||||
}
|
||||
|
||||
// Instantiate with a long interval, so that we can precisely control
|
||||
// the firing via force feeding.
|
||||
bticker := ticker.NewForce(time.Hour)
|
||||
aliceCfg := ChannelLinkConfig{
|
||||
FwrdingPolicy: globalPolicy,
|
||||
Peer: alicePeer,
|
||||
BestHeight: h.hSwitch.BestHeight,
|
||||
Circuits: h.hSwitch.CircuitModifier(),
|
||||
ForwardPackets: func(linkQuit chan struct{}, _ bool, packets ...*htlcPacket) error {
|
||||
return h.hSwitch.ForwardPackets(linkQuit, packets...)
|
||||
},
|
||||
FwrdingPolicy: globalPolicy,
|
||||
Peer: alicePeer,
|
||||
BestHeight: h.hSwitch.BestHeight,
|
||||
Circuits: h.hSwitch.CircuitModifier(),
|
||||
ForwardPackets: forwardPackets,
|
||||
DecodeHopIterators: decoder.DecodeHopIterators,
|
||||
ExtractErrorEncrypter: func(*btcec.PublicKey) (
|
||||
hop.ErrorEncrypter, lnwire.FailCode) {
|
||||
@@ -7037,7 +7045,7 @@ func TestPipelineSettle(t *testing.T) {
|
||||
// erroneously forwarded. If the forwardChan is closed before the last
|
||||
// step, then the test will fail.
|
||||
forwardChan := make(chan struct{})
|
||||
fwdPkts := func(c chan struct{}, _ bool, hp ...*htlcPacket) error {
|
||||
fwdPkts := func(c <-chan struct{}, _ bool, hp ...*htlcPacket) error {
|
||||
close(forwardChan)
|
||||
return nil
|
||||
}
|
||||
@@ -7223,7 +7231,7 @@ func TestChannelLinkShortFailureRelay(t *testing.T) {
|
||||
aliceMsgs := mockPeer.sentMsgs
|
||||
switchChan := make(chan *htlcPacket)
|
||||
|
||||
coreLink.cfg.ForwardPackets = func(linkQuit chan struct{}, _ bool,
|
||||
coreLink.cfg.ForwardPackets = func(linkQuit <-chan struct{}, _ bool,
|
||||
packets ...*htlcPacket) error {
|
||||
|
||||
for _, p := range packets {
|
||||
|
||||
Reference in new issue
Block a user