cnct: finish channel arbitrator in StateFullyResolved
Previously the arbitrator wasn't advanced to the final stage after the last contract resolved. Also channel arbitrator now does not ignore a log error anymore unresolved contracts cannot be retrieved.
This commit is contained in:
parent
b7387a5972
commit
9abe06f3c8
@ -816,7 +816,19 @@ func (c *ChannelArbitrator) stateStep(triggerHeight uint32,
|
|||||||
log.Infof("ChannelArbitrator(%v): still awaiting contract "+
|
log.Infof("ChannelArbitrator(%v): still awaiting contract "+
|
||||||
"resolution", c.cfg.ChanPoint)
|
"resolution", c.cfg.ChanPoint)
|
||||||
|
|
||||||
|
numUnresolved, err := c.log.FetchUnresolvedContracts()
|
||||||
|
if err != nil {
|
||||||
|
return StateError, closeTx, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we still have unresolved contracts, then we'll stay alive
|
||||||
|
// to oversee their resolution.
|
||||||
|
if len(numUnresolved) != 0 {
|
||||||
nextState = StateWaitingFullResolution
|
nextState = StateWaitingFullResolution
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
nextState = StateFullyResolved
|
||||||
|
|
||||||
// If we start as fully resolved, then we'll end as fully resolved.
|
// If we start as fully resolved, then we'll end as fully resolved.
|
||||||
case StateFullyResolved:
|
case StateFullyResolved:
|
||||||
@ -1722,29 +1734,22 @@ func (c *ChannelArbitrator) channelAttendant(bestHeight int32) {
|
|||||||
log.Infof("ChannelArbitrator(%v): a contract has been "+
|
log.Infof("ChannelArbitrator(%v): a contract has been "+
|
||||||
"fully resolved!", c.cfg.ChanPoint)
|
"fully resolved!", c.cfg.ChanPoint)
|
||||||
|
|
||||||
numUnresolved, err := c.log.FetchUnresolvedContracts()
|
nextState, _, err := c.advanceState(
|
||||||
|
uint32(bestHeight), chainTrigger,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("unable to query resolved "+
|
log.Errorf("unable to advance state: %v", err)
|
||||||
"contracts: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we still have unresolved contracts, then we'll
|
// If we don't have anything further to do after
|
||||||
// stay alive to oversee their resolution.
|
// advancing our state, then we'll exit.
|
||||||
if len(numUnresolved) != 0 {
|
if nextState == StateFullyResolved {
|
||||||
continue
|
log.Infof("ChannelArbitrator(%v): all "+
|
||||||
}
|
"contracts fully resolved, exiting",
|
||||||
|
c.cfg.ChanPoint)
|
||||||
|
|
||||||
log.Infof("ChannelArbitrator(%v): all contracts fully "+
|
|
||||||
"resolved, exiting", c.cfg.ChanPoint)
|
|
||||||
|
|
||||||
// Otherwise, our job is finished here, the contract is
|
|
||||||
// now fully resolved! We'll mark it as such, then exit
|
|
||||||
// ourselves.
|
|
||||||
if err := c.cfg.MarkChannelResolved(); err != nil {
|
|
||||||
log.Errorf("unable to mark contract "+
|
|
||||||
"resolved: %v", err)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// We've just received a request to forcibly close out the
|
// We've just received a request to forcibly close out the
|
||||||
// channel. We'll
|
// channel. We'll
|
||||||
|
@ -611,10 +611,7 @@ func TestChannelArbitratorLocalForceClosePendingHtlc(t *testing.T) {
|
|||||||
notifier.spendChan <- &chainntnfs.SpendDetail{}
|
notifier.spendChan <- &chainntnfs.SpendDetail{}
|
||||||
|
|
||||||
// At this point channel should be marked as resolved.
|
// At this point channel should be marked as resolved.
|
||||||
|
assertStateTransitions(t, arbLog.newStates, StateFullyResolved)
|
||||||
// It should transition StateWaitingFullResolution ->
|
|
||||||
// StateFullyResolved, but this isn't happening.
|
|
||||||
// assertStateTransitions(t, arbLog.newStates, StateFullyResolved)
|
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-resolved:
|
case <-resolved:
|
||||||
|
Loading…
Reference in New Issue
Block a user