mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-04 18:52:44 +02:00
multi: reliable hand-off from htlcswitch to contractcourt
This is achieved by changing the 1-way handoff to a 2-way handoff with a done channel.
This commit is contained in:
@@ -1122,6 +1122,17 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
|
||||
maxFeeUpdateTimeout = 40 * time.Minute
|
||||
)
|
||||
|
||||
notifyUpdateChan := make(chan *contractcourt.ContractUpdate)
|
||||
doneChan := make(chan struct{})
|
||||
notifyContractUpdate := func(u *contractcourt.ContractUpdate) error {
|
||||
select {
|
||||
case notifyUpdateChan <- u:
|
||||
case <-doneChan:
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
link := NewChannelLink(
|
||||
ChannelLinkConfig{
|
||||
Switch: server.htlcSwitch,
|
||||
@@ -1142,6 +1153,7 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
|
||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||
return nil
|
||||
},
|
||||
NotifyContractUpdate: notifyContractUpdate,
|
||||
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||
SyncStates: true,
|
||||
BatchSize: 10,
|
||||
@@ -1169,8 +1181,9 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-link.(*channelLink).htlcUpdates:
|
||||
case <-notifyUpdateChan:
|
||||
case <-link.(*channelLink).quit:
|
||||
close(doneChan)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user