cnct: do not log resolver shutting down as error

This commit is contained in:
Joost Jager 2019-09-11 15:53:00 +02:00
parent 2dd23819bb
commit ecd3c59f7a
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
7 changed files with 33 additions and 25 deletions

@ -1866,6 +1866,10 @@ func (c *ChannelArbitrator) resolveContract(currentContract ContractResolver) {
// contract.
nextContract, err := currentContract.Resolve()
if err != nil {
if err == errResolverShuttingDown {
return
}
log.Errorf("ChannelArbitrator(%v): unable to "+
"progress resolver: %v",
c.cfg.ChanPoint, err)

@ -2,7 +2,6 @@ package contractcourt
import (
"encoding/binary"
"fmt"
"io"
"github.com/btcsuite/btcd/wire"
@ -78,11 +77,11 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
select {
case _, ok := <-confNtfn.Confirmed:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
case <-c.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// We're dealing with our commitment transaction if the delay on the
@ -129,7 +128,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
log.Infof("ChannelPoint(%v) commit tx is fully resolved by "+
"sweep tx: %v", c.chanPoint, sweepResult.Tx.TxHash())
case <-c.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
c.resolved = true
@ -155,7 +154,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
select {
case commitSpend, ok := <-spendNtfn.Spend:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// Once we detect the commitment output has been spent,
@ -171,7 +170,7 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
return nil, err
}
case <-c.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
log.Infof("%T(%v): waiting for commit sweep txid=%v conf", c, c.chanPoint,
@ -190,14 +189,14 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
select {
case confInfo, ok := <-confNtfn.Confirmed:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
log.Infof("ChannelPoint(%v) commit tx is fully resolved, at height: %v",
c.chanPoint, confInfo.BlockHeight)
case <-c.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// Once the transaction has received a sufficient number of

@ -2,6 +2,7 @@ package contractcourt
import (
"encoding/binary"
"errors"
"io"
)
@ -83,3 +84,9 @@ type ResolverKit struct {
Quit chan struct{}
}
var (
// errResolverShuttingDown is returned when the resolver stops
// progressing because it received the quit signal.
errResolverShuttingDown = errors.New("resolver shutting down")
)

@ -3,7 +3,6 @@ package contractcourt
import (
"encoding/binary"
"errors"
"fmt"
"io"
"github.com/lightningnetwork/lnd/channeldb"
@ -66,11 +65,11 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
select {
case newBlock, ok := <-blockEpochs.Epochs:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
currentHeight = newBlock.Height
case <-h.Quit:
return nil, fmt.Errorf("resolver stopped")
return nil, errResolverShuttingDown
}
// We'll first check if this HTLC has been timed out, if so, we can
@ -224,7 +223,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
case newBlock, ok := <-blockEpochs.Epochs:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// If this new height expires the HTLC, then this means
@ -241,7 +240,7 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
}
case <-h.Quit:
return nil, fmt.Errorf("resolver stopped")
return nil, errResolverShuttingDown
}
}
}

@ -65,7 +65,7 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
// sweep the pre-image from the output.
case commitSpend, ok := <-spendNtfn.Spend:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// TODO(roasbeef): Checkpoint?
@ -122,7 +122,7 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
// HTLC expiration.
case newBlock, ok := <-blockEpochs.Epochs:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// If this new height expires the HTLC, then we can
@ -142,7 +142,7 @@ func (h *htlcOutgoingContestResolver) Resolve() (ContractResolver, error) {
// revealed on-chain.
case commitSpend, ok := <-spendNtfn.Spend:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// The only way this output can be spent by the remote

@ -2,7 +2,6 @@ package contractcourt
import (
"encoding/binary"
"fmt"
"io"
"github.com/btcsuite/btcd/wire"
@ -171,11 +170,11 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
select {
case _, ok := <-confNtfn.Confirmed:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
case <-h.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// Once the transaction has received a sufficient number of
@ -236,11 +235,11 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) {
select {
case _, ok := <-spendNtfn.Spend:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
case <-h.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
h.resolved = true

@ -271,11 +271,11 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) {
select {
case _, ok := <-spendNtfn.Spend:
if !ok {
return fmt.Errorf("notifier quit")
return errResolverShuttingDown
}
case <-h.Quit:
return fmt.Errorf("quitting")
return errResolverShuttingDown
}
return nil
@ -309,11 +309,11 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) {
select {
case spend, ok = <-spendNtfn.Spend:
if !ok {
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
case <-h.Quit:
return nil, fmt.Errorf("quitting")
return nil, errResolverShuttingDown
}
// If the spend reveals the pre-image, then we'll enter the clean up