contractcourt: fix off-by-one error in closeObserver case
In this commit, we fix an off-by-one error when handling force closes from the remote party. Before this commit, if the remote party broadcasts state 2, and we were on state 1, then we wouldn't act at all. This is due to an extraneous +1 in the comparison, causing us to only detect this DLP case if the remote party's state is two beyond what we know atm. Before this commit, the test added in the prior commit failed.
This commit is contained in:
parent
795c9f1550
commit
6983a9e146
@ -406,11 +406,12 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) {
|
||||
c.cfg.chanState.FundingOutpoint, err)
|
||||
}
|
||||
|
||||
// This is the case that somehow the commitment broadcast is
|
||||
// actually greater than even one beyond our best known state
|
||||
// number. This should ONLY happen in case we experienced some
|
||||
// sort of data loss.
|
||||
case broadcastStateNum > remoteStateNum+1:
|
||||
// If the remote party has broadcasted a state beyond our best
|
||||
// known state for them, and they don't have a pending
|
||||
// commitment (we write them to disk before sending out), then
|
||||
// this means that we've lost data. In this case, we'll enter
|
||||
// the DLP protocol.
|
||||
case broadcastStateNum > remoteStateNum:
|
||||
log.Warnf("Remote node broadcast state #%v, "+
|
||||
"which is more than 1 beyond best known "+
|
||||
"state #%v!!! Attempting recovery...",
|
||||
|
Loading…
Reference in New Issue
Block a user