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.
|
// been closed, or when the set of active HTLC's is updated.
|
||||||
UpdateContractSignals func(*contractcourt.ContractSignals) error
|
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
|
// FeeEstimator is an instance of a live fee estimator which will be
|
||||||
// used to dynamically regulate the current fee of the commitment
|
// used to dynamically regulate the current fee of the commitment
|
||||||
// transaction to ensure timely confirmation.
|
// transaction to ensure timely confirmation.
|
||||||
@ -286,7 +291,6 @@ func (l *channelLink) Start() error {
|
|||||||
// set of new channel signals for this channel.
|
// set of new channel signals for this channel.
|
||||||
if err := l.cfg.UpdateContractSignals(&contractcourt.ContractSignals{
|
if err := l.cfg.UpdateContractSignals(&contractcourt.ContractSignals{
|
||||||
HtlcUpdates: l.htlcUpdates,
|
HtlcUpdates: l.htlcUpdates,
|
||||||
UniCloseSignal: l.channel.UnilateralClose,
|
|
||||||
ShortChanID: l.channel.ShortChanID(),
|
ShortChanID: l.channel.ShortChanID(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -313,6 +317,10 @@ func (l *channelLink) Stop() {
|
|||||||
|
|
||||||
log.Infof("ChannelLink(%v) is stopping", l)
|
log.Infof("ChannelLink(%v) is stopping", l)
|
||||||
|
|
||||||
|
if l.cfg.ChainEvents.Cancel != nil {
|
||||||
|
l.cfg.ChainEvents.Cancel()
|
||||||
|
}
|
||||||
|
|
||||||
l.channel.Stop()
|
l.channel.Stop()
|
||||||
|
|
||||||
l.mailBox.Stop()
|
l.mailBox.Stop()
|
||||||
@ -631,10 +639,12 @@ out:
|
|||||||
// carried out by the remote peer. In the case of such an
|
// carried out by the remote peer. In the case of such an
|
||||||
// event, we'll wipe the channel state from the peer, and mark
|
// event, we'll wipe the channel state from the peer, and mark
|
||||||
// the contract as fully settled. Afterwards we can exit.
|
// 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",
|
log.Warnf("Remote peer has closed ChannelPoint(%v) on-chain",
|
||||||
l.channel.ChannelPoint())
|
l.channel.ChannelPoint())
|
||||||
|
|
||||||
|
// TODO(roasbeef): move this and above to chainJanitor
|
||||||
|
|
||||||
// TODO(roasbeef): remove all together
|
// TODO(roasbeef): remove all together
|
||||||
go func() {
|
go func() {
|
||||||
chanPoint := l.channel.ChannelPoint()
|
chanPoint := l.channel.ChannelPoint()
|
||||||
@ -649,17 +659,6 @@ out:
|
|||||||
|
|
||||||
break 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:
|
case <-l.logCommitTick:
|
||||||
// If we haven't sent or received a new commitment
|
// If we haven't sent or received a new commitment
|
||||||
// update in some time, check to see if we have any
|
// 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
|
return nil
|
||||||
},
|
},
|
||||||
Registry: invoiveRegistry,
|
Registry: invoiveRegistry,
|
||||||
|
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||||
BlockEpochs: globalEpoch,
|
BlockEpochs: globalEpoch,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,13 +268,13 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
channelAlice, err := lnwallet.NewLightningChannel(
|
channelAlice, err := lnwallet.NewLightningChannel(
|
||||||
aliceSigner, nil, pCache, aliceChannelState,
|
aliceSigner, pCache, aliceChannelState,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
channelBob, err := lnwallet.NewLightningChannel(
|
channelBob, err := lnwallet.NewLightningChannel(
|
||||||
bobSigner, nil, pCache, bobChannelState,
|
bobSigner, pCache, bobChannelState,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
@ -319,7 +319,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
|||||||
}
|
}
|
||||||
|
|
||||||
newAliceChannel, err := lnwallet.NewLightningChannel(aliceSigner,
|
newAliceChannel, err := lnwallet.NewLightningChannel(aliceSigner,
|
||||||
nil, nil, aliceStoredChannel)
|
nil, aliceStoredChannel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Errorf("unable to create new channel: %v",
|
return nil, nil, errors.Errorf("unable to create new channel: %v",
|
||||||
err)
|
err)
|
||||||
@ -343,7 +343,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
|
|||||||
return nil, nil, errors.New("unable to find stored bob channel")
|
return nil, nil, errors.New("unable to find stored bob channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
newBobChannel, err := lnwallet.NewLightningChannel(bobSigner, nil,
|
newBobChannel, err := lnwallet.NewLightningChannel(bobSigner,
|
||||||
nil, bobStoredChannel)
|
nil, bobStoredChannel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, errors.Errorf("unable to create new channel: %v",
|
return nil, nil, errors.Errorf("unable to create new channel: %v",
|
||||||
@ -761,6 +761,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
|||||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||||
SyncStates: true,
|
SyncStates: true,
|
||||||
},
|
},
|
||||||
aliceChannel,
|
aliceChannel,
|
||||||
@ -799,6 +800,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
|||||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||||
SyncStates: true,
|
SyncStates: true,
|
||||||
},
|
},
|
||||||
firstBobChannel,
|
firstBobChannel,
|
||||||
@ -837,6 +839,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
|||||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||||
SyncStates: true,
|
SyncStates: true,
|
||||||
},
|
},
|
||||||
secondBobChannel,
|
secondBobChannel,
|
||||||
@ -875,6 +878,7 @@ func newThreeHopNetwork(t testing.TB, aliceChannel, firstBobChannel,
|
|||||||
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
UpdateContractSignals: func(*contractcourt.ContractSignals) error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
ChainEvents: &contractcourt.ChainEventSubscription{},
|
||||||
SyncStates: true,
|
SyncStates: true,
|
||||||
},
|
},
|
||||||
carolChannel,
|
carolChannel,
|
||||||
|
@ -400,7 +400,7 @@ func (ns *nurseryStore) CribToKinder(bby *babyOutput) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
utxnLog.Tracef("Placing (crib -> baby) output for "+
|
utxnLog.Tracef("Transitioning (crib -> baby) output for "+
|
||||||
"chan_point=%v at height_index=%v", chanPoint,
|
"chan_point=%v at height_index=%v", chanPoint,
|
||||||
maturityHeight)
|
maturityHeight)
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ func (ns *nurseryStore) PreschoolToKinder(kid *kidOutput) error {
|
|||||||
maturityHeight = lastGradHeight + 1
|
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,
|
"chan_point=%v at height_index=%v", chanPoint,
|
||||||
maturityHeight)
|
maturityHeight)
|
||||||
|
|
||||||
|
@ -222,13 +222,13 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
|
|||||||
bobSigner := &mockSigner{bobKeyPriv}
|
bobSigner := &mockSigner{bobKeyPriv}
|
||||||
|
|
||||||
channelAlice, err := lnwallet.NewLightningChannel(
|
channelAlice, err := lnwallet.NewLightningChannel(
|
||||||
aliceSigner, notifier, nil, aliceChannelState,
|
aliceSigner, nil, aliceChannelState,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
}
|
}
|
||||||
channelBob, err := lnwallet.NewLightningChannel(
|
channelBob, err := lnwallet.NewLightningChannel(
|
||||||
bobSigner, notifier, nil, bobChannelState,
|
bobSigner, nil, bobChannelState,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, nil, err
|
return nil, nil, nil, nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user