htlcswitch: update to use new event stream from the chainWatcher
This commit is contained in:
parent
69e6ec9954
commit
239416f242
@ -135,6 +135,11 @@ type ChannelLinkConfig struct {
|
||||
// been closed, or when the set of active HTLC's is updated.
|
||||
UpdateContractSignals func(*contractcourt.ContractSignals) error
|
||||
|
||||
// ChainEvents is an active subscription to the chain watcher for this
|
||||
// channel to be notified of any on-chain activity related to this
|
||||
// channel.
|
||||
ChainEvents *contractcourt.ChainEventSubscription
|
||||
|
||||
// FeeEstimator is an instance of a live fee estimator which will be
|
||||
// used to dynamically regulate the current fee of the commitment
|
||||
// transaction to ensure timely confirmation.
|
||||
@ -285,9 +290,8 @@ func (l *channelLink) Start() error {
|
||||
// Before we start the link, we'll update the ChainArbitrator with the
|
||||
// set of new channel signals for this channel.
|
||||
if err := l.cfg.UpdateContractSignals(&contractcourt.ContractSignals{
|
||||
HtlcUpdates: l.htlcUpdates,
|
||||
UniCloseSignal: l.channel.UnilateralClose,
|
||||
ShortChanID: l.channel.ShortChanID(),
|
||||
HtlcUpdates: l.htlcUpdates,
|
||||
ShortChanID: l.channel.ShortChanID(),
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -313,6 +317,10 @@ func (l *channelLink) Stop() {
|
||||
|
||||
log.Infof("ChannelLink(%v) is stopping", l)
|
||||
|
||||
if l.cfg.ChainEvents.Cancel != nil {
|
||||
l.cfg.ChainEvents.Cancel()
|
||||
}
|
||||
|
||||
l.channel.Stop()
|
||||
|
||||
l.mailBox.Stop()
|
||||
@ -631,10 +639,12 @@ out:
|
||||
// carried out by the remote peer. In the case of such an
|
||||
// event, we'll wipe the channel state from the peer, and mark
|
||||
// the contract as fully settled. Afterwards we can exit.
|
||||
case <-l.channel.UnilateralCloseSignal:
|
||||
case <-l.cfg.ChainEvents.UnilateralClosure:
|
||||
log.Warnf("Remote peer has closed ChannelPoint(%v) on-chain",
|
||||
l.channel.ChannelPoint())
|
||||
|
||||
// TODO(roasbeef): move this and above to chainJanitor
|
||||
|
||||
// TODO(roasbeef): remove all together
|
||||
go func() {
|
||||
chanPoint := l.channel.ChannelPoint()
|
||||
@ -649,17 +659,6 @@ out:
|
||||
|
||||
break out
|
||||
|
||||
// A local sub-system has initiated a force close of the active
|
||||
// channel. In this case we can exit immediately as no further
|
||||
// updates should be processed for the channel.
|
||||
case <-l.channel.ForceCloseSignal:
|
||||
// TODO(roasbeef): path never taken now that server
|
||||
// force closes's directly?
|
||||
log.Warnf("ChannelPoint(%v) has been force "+
|
||||
"closed, disconnecting from peer(%x)",
|
||||
l.channel.ChannelPoint(), l.cfg.Peer.PubKey())
|
||||
break out
|
||||
|
||||
case <-l.logCommitTick:
|
||||
// If we haven't sent or received a new commitment
|
||||
// update in some time, check to see if we have any
|
||||
|
@ -1465,6 +1465,7 @@ func newSingleLinkTestHarness(chanAmt btcutil.Amount) (ChannelLink, func(), erro
|
||||
return nil
|
||||
},
|
||||
Registry: invoiveRegistry,
|
||||
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||
BlockEpochs: globalEpoch,
|
||||
}
|
||||
|
||||
|
@ -268,13 +268,13 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
}
|
||||
|
||||
channelAlice, err := lnwallet.NewLightningChannel(
|
||||
aliceSigner, nil, pCache, aliceChannelState,
|
||||
aliceSigner, pCache, aliceChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
channelBob, err := lnwallet.NewLightningChannel(
|
||||
bobSigner, nil, pCache, bobChannelState,
|
||||
bobSigner, pCache, bobChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
@ -319,7 +319,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
}
|
||||
|
||||
newAliceChannel, err := lnwallet.NewLightningChannel(aliceSigner,
|
||||
nil, nil, aliceStoredChannel)
|
||||
nil, aliceStoredChannel)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("unable to create new channel: %v",
|
||||
err)
|
||||
@ -343,7 +343,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
||||
return nil, nil, errors.New("unable to find stored bob channel")
|
||||
}
|
||||
|
||||
newBobChannel, err := lnwallet.NewLightningChannel(bobSigner, nil,
|
||||
newBobChannel, err := lnwallet.NewLightningChannel(bobSigner,
|
||||
nil, bobStoredChannel)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("unable to create new channel: %v",
|
||||
@ -761,7 +761,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||
return nil
|
||||
},
|
||||
SyncStates: true,
|
||||
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||
SyncStates: true,
|
||||
},
|
||||
aliceChannel,
|
||||
startingHeight,
|
||||
@ -799,7 +800,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||
return nil
|
||||
},
|
||||
SyncStates: true,
|
||||
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||
SyncStates: true,
|
||||
},
|
||||
firstBobChannel,
|
||||
startingHeight,
|
||||
@ -837,7 +839,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||
return nil
|
||||
},
|
||||
SyncStates: true,
|
||||
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||
SyncStates: true,
|
||||
},
|
||||
secondBobChannel,
|
||||
startingHeight,
|
||||
@ -875,7 +878,8 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||
return nil
|
||||
},
|
||||
SyncStates: true,
|
||||
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||
SyncStates: true,
|
||||
},
|
||||
carolChannel,
|
||||
startingHeight,
|
||||
|
@ -400,7 +400,7 @@ func (ns *nurseryStore) CribToKinder(bby *babyOutput) error {
|
||||
return err
|
||||
}
|
||||
|
||||
utxnLog.Tracef("Placing (crib -> baby) output for "+
|
||||
utxnLog.Tracef("Transitioning (crib -> baby) output for "+
|
||||
"chan_point=%v at height_index=%v", chanPoint,
|
||||
maturityHeight)
|
||||
|
||||
@ -494,7 +494,7 @@ func (ns *nurseryStore) PreschoolToKinder(kid *kidOutput) error {
|
||||
maturityHeight = lastGradHeight + 1
|
||||
}
|
||||
|
||||
utxnLog.Tracef("Placing (crib -> kid) output for "+
|
||||
utxnLog.Infof("Transitioning (crib -> kid) output for "+
|
||||
"chan_point=%v at height_index=%v", chanPoint,
|
||||
maturityHeight)
|
||||
|
||||
|
@ -222,13 +222,13 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
|
||||
bobSigner := &mockSigner{bobKeyPriv}
|
||||
|
||||
channelAlice, err := lnwallet.NewLightningChannel(
|
||||
aliceSigner, notifier, nil, aliceChannelState,
|
||||
aliceSigner, nil, aliceChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
channelBob, err := lnwallet.NewLightningChannel(
|
||||
bobSigner, notifier, nil, bobChannelState,
|
||||
bobSigner, nil, bobChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user