mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 22:42:29 +02:00
contractcourt: replace MarkChannelClosed
with NotifyChannelResolved
This commit is contained in:
@@ -465,6 +465,9 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
|
||||
channel.ShortChanID(), htlc,
|
||||
)
|
||||
},
|
||||
NotifyChannelResolved: func() {
|
||||
c.notifyChannelResolved(chanPoint)
|
||||
},
|
||||
}
|
||||
|
||||
// The final component needed is an arbitrator log that the arbitrator
|
||||
@@ -480,14 +483,6 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
arbCfg.MarkChannelResolved = func() error {
|
||||
if c.cfg.NotifyFullyResolvedChannel != nil {
|
||||
c.cfg.NotifyFullyResolvedChannel(chanPoint)
|
||||
}
|
||||
|
||||
return c.ResolveContract(chanPoint)
|
||||
}
|
||||
|
||||
// Finally, we'll need to construct a series of htlc Sets based on all
|
||||
// currently known valid commitments.
|
||||
htlcSets := make(map[HtlcSetKey]htlcSet)
|
||||
@@ -1399,6 +1394,9 @@ func (c *ChainArbitrator) loadPendingCloseChannels() error {
|
||||
closeChanInfo.ShortChanID, htlc,
|
||||
)
|
||||
},
|
||||
NotifyChannelResolved: func() {
|
||||
c.notifyChannelResolved(chanPoint)
|
||||
},
|
||||
}
|
||||
chanLog, err := newBoltArbitratorLog(
|
||||
c.chanSource.Backend, arbCfg, c.cfg.ChainHash, chanPoint,
|
||||
@@ -1406,13 +1404,6 @@ func (c *ChainArbitrator) loadPendingCloseChannels() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
arbCfg.MarkChannelResolved = func() error {
|
||||
if c.cfg.NotifyFullyResolvedChannel != nil {
|
||||
c.cfg.NotifyFullyResolvedChannel(chanPoint)
|
||||
}
|
||||
|
||||
return c.ResolveContract(chanPoint)
|
||||
}
|
||||
|
||||
// We create an empty map of HTLC's here since it's possible
|
||||
// that the channel is in StateDefault and updateActiveHTLCs is
|
||||
|
@@ -153,13 +153,9 @@ type ChannelArbitratorConfig struct {
|
||||
// true. Otherwise this value is unset.
|
||||
CloseType channeldb.ClosureType
|
||||
|
||||
// MarkChannelResolved is a function closure that serves to mark a
|
||||
// channel as "fully resolved". A channel itself can be considered
|
||||
// fully resolved once all active contracts have individually been
|
||||
// fully resolved.
|
||||
//
|
||||
// TODO(roasbeef): need RPC's to combine for pendingchannels RPC
|
||||
MarkChannelResolved func() error
|
||||
// NotifyChannelResolved is used by the channel arbitrator to signal
|
||||
// that a given channel has been resolved.
|
||||
NotifyChannelResolved func()
|
||||
|
||||
// PutResolverReport records a resolver report for the channel. If the
|
||||
// transaction provided is nil, the function should write the report
|
||||
@@ -1397,10 +1393,7 @@ func (c *ChannelArbitrator) stateStep(
|
||||
log.Infof("ChannelPoint(%v) has been fully resolved "+
|
||||
"on-chain at height=%v", c.cfg.ChanPoint, triggerHeight)
|
||||
|
||||
if err := c.cfg.MarkChannelResolved(); err != nil {
|
||||
log.Errorf("unable to mark channel resolved: %v", err)
|
||||
return StateError, closeTx, err
|
||||
}
|
||||
c.cfg.NotifyChannelResolved()
|
||||
}
|
||||
|
||||
log.Tracef("ChannelArbitrator(%v): next_state=%v", c.cfg.ChanPoint,
|
||||
|
@@ -417,7 +417,7 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog,
|
||||
}
|
||||
|
||||
// We'll use the resolvedChan to synchronize on call to
|
||||
// MarkChannelResolved.
|
||||
// NotifyChannelResolved.
|
||||
resolvedChan := make(chan struct{}, 1)
|
||||
|
||||
// Next we'll create the matching configuration struct that contains
|
||||
@@ -425,9 +425,8 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog,
|
||||
arbCfg := &ChannelArbitratorConfig{
|
||||
ChanPoint: chanPoint,
|
||||
ShortChanID: shortChanID,
|
||||
MarkChannelResolved: func() error {
|
||||
NotifyChannelResolved: func() {
|
||||
resolvedChan <- struct{}{}
|
||||
return nil
|
||||
},
|
||||
MarkCommitmentBroadcasted: func(_ *wire.MsgTx,
|
||||
_ lntypes.ChannelParty) error {
|
||||
@@ -547,7 +546,7 @@ func TestChannelArbitratorCooperativeClose(t *testing.T) {
|
||||
}
|
||||
|
||||
// Cooperative close should do trigger a MarkChannelClosed +
|
||||
// MarkChannelResolved.
|
||||
// NotifyChannelResolved.
|
||||
closeInfo := &CooperativeCloseInfo{
|
||||
&channeldb.ChannelCloseSummary{},
|
||||
}
|
||||
|
Reference in New Issue
Block a user