server+contractcourt: hand-off BreachCloseInfo to channel arbitrator
This also changes the chain_watcher and breacharbiter handoff. The new logic ensures that the channel is only marked as pending closed when the channel arbitrator has persisted the resolutions and commit set.
This commit is contained in:
1 parent
b7407882ac
commit
ebaffb953a
5 files changed
+289
-89
No files matched your search
@@ -100,14 +100,12 @@ type ChainArbitratorConfig struct {
|
||||
MarkLinkInactive func(wire.OutPoint) error
|
||||
|
||||
// ContractBreach is a function closure that the ChainArbitrator will
|
||||
// use to notify the breachArbiter about a contract breach. A callback
|
||||
// should be passed that when called will mark the channel pending
|
||||
// close in the database. It should only return a non-nil error when the
|
||||
// breachArbiter has preserved the necessary breach info for this
|
||||
// channel point, and the callback has succeeded, meaning it is safe to
|
||||
// stop watching the channel.
|
||||
ContractBreach func(wire.OutPoint, *lnwallet.BreachRetribution,
|
||||
func() error) error
|
||||
// use to notify the breachArbiter about a contract breach. It should
|
||||
// only return a non-nil error when the breachArbiter has preserved
|
||||
// the necessary breach info for this channel point. Once the breach
|
||||
// resolution is persisted in the channel arbitrator, it will be safe
|
||||
// to mark the channel closed.
|
||||
ContractBreach func(wire.OutPoint, *lnwallet.BreachRetribution) error
|
||||
|
||||
// IsOurAddress is a function that returns true if the passed address
|
||||
// is known to the underlying wallet. Otherwise, false should be
|
||||
@@ -512,19 +510,17 @@ func (c *ChainArbitrator) Start() error {
|
||||
|
||||
// First, we'll create an active chainWatcher for this channel
|
||||
// to ensure that we detect any relevant on chain events.
|
||||
breachClosure := func(ret *lnwallet.BreachRetribution) error {
|
||||
return c.cfg.ContractBreach(chanPoint, ret)
|
||||
}
|
||||
|
||||
chainWatcher, err := newChainWatcher(
|
||||
chainWatcherConfig{
|
||||
chanState: channel,
|
||||
notifier: c.cfg.Notifier,
|
||||
signer: c.cfg.Signer,
|
||||
isOurAddr: c.cfg.IsOurAddress,
|
||||
contractBreach: func(retInfo *lnwallet.BreachRetribution,
|
||||
markClosed func() error) error {
|
||||
|
||||
return c.cfg.ContractBreach(
|
||||
chanPoint, retInfo, markClosed,
|
||||
)
|
||||
},
|
||||
chanState: channel,
|
||||
notifier: c.cfg.Notifier,
|
||||
signer: c.cfg.Signer,
|
||||
isOurAddr: c.cfg.IsOurAddress,
|
||||
contractBreach: breachClosure,
|
||||
extractStateNumHint: lnwallet.GetStateNumHint,
|
||||
},
|
||||
)
|
||||
@@ -1122,11 +1118,11 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error
|
||||
notifier: c.cfg.Notifier,
|
||||
signer: c.cfg.Signer,
|
||||
isOurAddr: c.cfg.IsOurAddress,
|
||||
contractBreach: func(retInfo *lnwallet.BreachRetribution,
|
||||
markClosed func() error) error {
|
||||
contractBreach: func(
|
||||
retInfo *lnwallet.BreachRetribution) error {
|
||||
|
||||
return c.cfg.ContractBreach(
|
||||
chanPoint, retInfo, markClosed,
|
||||
chanPoint, retInfo,
|
||||
)
|
||||
},
|
||||
extractStateNumHint: lnwallet.GetStateNumHint,
|
||||
|
||||
Reference in new issue
Block a user