contractcourt/chain_arbitrator: mark commitment broadcasted before publish
Before publishing the close tx to the network and commit to the StateCommitmentBroadcasted state, we mark the commitment as broadcasted and store it to the db. This ensures it will get re-published on startup if we go down.
This commit is contained in:
parent
9423fadf56
commit
2cb80c4449
@ -821,6 +821,16 @@ func (c *ChannelArbitrator) stateStep(
|
||||
}
|
||||
closeTx = closeSummary.CloseTx
|
||||
|
||||
// Before publishing the transaction, we store it to the
|
||||
// database, such that we can re-publish later in case it
|
||||
// didn't propagate.
|
||||
if err := c.cfg.MarkCommitmentBroadcasted(closeTx); err != nil {
|
||||
log.Errorf("ChannelArbitrator(%v): unable to "+
|
||||
"mark commitment broadcasted: %v",
|
||||
c.cfg.ChanPoint, err)
|
||||
return StateError, closeTx, err
|
||||
}
|
||||
|
||||
// With the close transaction in hand, broadcast the
|
||||
// transaction to the network, thereby entering the post
|
||||
// channel resolution state.
|
||||
@ -840,12 +850,6 @@ func (c *ChannelArbitrator) stateStep(
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.cfg.MarkCommitmentBroadcasted(closeTx); err != nil {
|
||||
log.Errorf("ChannelArbitrator(%v): unable to "+
|
||||
"mark commitment broadcasted: %v",
|
||||
c.cfg.ChanPoint, err)
|
||||
}
|
||||
|
||||
// We go to the StateCommitmentBroadcasted state, where we'll
|
||||
// be waiting for the commitment to be confirmed.
|
||||
nextState = StateCommitmentBroadcasted
|
||||
|
Loading…
Reference in New Issue
Block a user