mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
chainntnfs: declare common ErrChainNotifierShuttingDown for all backends
This commit is contained in:
parent
50650d054e
commit
be2c321c8c
4 changed files with 20 additions and 33 deletions
|
@ -26,11 +26,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrChainNotifierShuttingDown is used when we are trying to
|
|
||||||
// measure a spend notification when notifier is already stopped.
|
|
||||||
ErrChainNotifierShuttingDown = errors.New("chainntnfs: system interrupt " +
|
|
||||||
"while attempting to register for spend notification.")
|
|
||||||
|
|
||||||
// ErrTransactionNotFound is an error returned when we attempt to find a
|
// ErrTransactionNotFound is an error returned when we attempt to find a
|
||||||
// transaction by manually scanning the chain within a specific range
|
// transaction by manually scanning the chain within a specific range
|
||||||
// but it is not found.
|
// but it is not found.
|
||||||
|
@ -498,7 +493,6 @@ func (b *BitcoindNotifier) confDetailsFromTxIndex(txid *chainhash.Hash,
|
||||||
fmt.Errorf("unable to get block hash %v for "+
|
fmt.Errorf("unable to get block hash %v for "+
|
||||||
"historical dispatch: %v", rawTxRes.BlockHash, err)
|
"historical dispatch: %v", rawTxRes.BlockHash, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
block, err := b.chainConn.GetBlockVerbose(blockHash)
|
block, err := b.chainConn.GetBlockVerbose(blockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, chainntnfs.TxNotFoundIndex,
|
return nil, chainntnfs.TxNotFoundIndex,
|
||||||
|
@ -559,7 +553,7 @@ func (b *BitcoindNotifier) confDetailsManually(confRequest chainntnfs.ConfReques
|
||||||
select {
|
select {
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return nil, chainntnfs.TxNotFoundManually,
|
return nil, chainntnfs.TxNotFoundManually,
|
||||||
ErrChainNotifierShuttingDown
|
chainntnfs.ErrChainNotifierShuttingDown
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +722,7 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||||
select {
|
select {
|
||||||
case b.notificationRegistry <- historicalDispatch:
|
case b.notificationRegistry <- historicalDispatch:
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
return ntfn.Event, nil
|
return ntfn.Event, nil
|
||||||
|
@ -805,7 +799,7 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||||
select {
|
select {
|
||||||
case b.notificationRegistry <- historicalDispatch:
|
case b.notificationRegistry <- historicalDispatch:
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
return ntfn.Event, nil
|
return ntfn.Event, nil
|
||||||
|
@ -829,7 +823,7 @@ func (b *BitcoindNotifier) dispatchSpendDetailsManually(
|
||||||
// processing the next height.
|
// processing the next height.
|
||||||
select {
|
select {
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return ErrChainNotifierShuttingDown
|
return chainntnfs.ErrChainNotifierShuttingDown
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,7 +917,7 @@ func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||||
case b.notificationRegistry <- dispatch:
|
case b.notificationRegistry <- dispatch:
|
||||||
return ntfn.Event, nil
|
return ntfn.Event, nil
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,6 @@ const (
|
||||||
notifierType = "btcd"
|
notifierType = "btcd"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrChainNotifierShuttingDown is used when we are trying to
|
|
||||||
// measure a spend notification when notifier is already stopped.
|
|
||||||
ErrChainNotifierShuttingDown = errors.New("chainntnfs: system interrupt " +
|
|
||||||
"while attempting to register for spend notification.")
|
|
||||||
)
|
|
||||||
|
|
||||||
// chainUpdate encapsulates an update to the current main chain. This struct is
|
// chainUpdate encapsulates an update to the current main chain. This struct is
|
||||||
// used as an element within an unbounded queue in order to avoid blocking the
|
// used as an element within an unbounded queue in order to avoid blocking the
|
||||||
// main rpc dispatch rule.
|
// main rpc dispatch rule.
|
||||||
|
@ -610,7 +603,7 @@ func (b *BtcdNotifier) confDetailsManually(confRequest chainntnfs.ConfRequest,
|
||||||
select {
|
select {
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return nil, chainntnfs.TxNotFoundManually,
|
return nil, chainntnfs.TxNotFoundManually,
|
||||||
ErrChainNotifierShuttingDown
|
chainntnfs.ErrChainNotifierShuttingDown
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,7 +957,7 @@ func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||||
case b.notificationRegistry <- dispatch:
|
case b.notificationRegistry <- dispatch:
|
||||||
return ntfn.Event, nil
|
return ntfn.Event, nil
|
||||||
case <-b.quit:
|
case <-b.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package chainntnfs
|
package chainntnfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
@ -9,6 +10,12 @@ import (
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrChainNotifierShuttingDown is used when we are trying to
|
||||||
|
// measure a spend notification when notifier is already stopped.
|
||||||
|
ErrChainNotifierShuttingDown = errors.New("chain notifier shutting down")
|
||||||
|
)
|
||||||
|
|
||||||
// TxConfStatus denotes the status of a transaction's lookup.
|
// TxConfStatus denotes the status of a transaction's lookup.
|
||||||
type TxConfStatus uint8
|
type TxConfStatus uint8
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,6 @@ const (
|
||||||
notifierType = "neutrino"
|
notifierType = "neutrino"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrChainNotifierShuttingDown is used when we are trying to
|
|
||||||
// measure a spend notification when notifier is already stopped.
|
|
||||||
ErrChainNotifierShuttingDown = errors.New("chainntnfs: system interrupt " +
|
|
||||||
"while attempting to register for spend notification.")
|
|
||||||
)
|
|
||||||
|
|
||||||
// NeutrinoNotifier is a version of ChainNotifier that's backed by the neutrino
|
// NeutrinoNotifier is a version of ChainNotifier that's backed by the neutrino
|
||||||
// Bitcoin light client. Unlike other implementations, this implementation
|
// Bitcoin light client. Unlike other implementations, this implementation
|
||||||
// speaks directly to the p2p network. As a result, this implementation of the
|
// speaks directly to the p2p network. As a result, this implementation of the
|
||||||
|
@ -503,7 +496,7 @@ func (n *NeutrinoNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
|
||||||
// processing the next height.
|
// processing the next height.
|
||||||
select {
|
select {
|
||||||
case <-n.quit:
|
case <-n.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,13 +703,13 @@ func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||||
errChan: errChan,
|
errChan: errChan,
|
||||||
}:
|
}:
|
||||||
case <-n.quit:
|
case <-n.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-errChan:
|
case err = <-errChan:
|
||||||
case <-n.quit:
|
case <-n.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to update filter: %v", err)
|
return nil, fmt.Errorf("unable to update filter: %v", err)
|
||||||
|
@ -856,13 +849,13 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||||
errChan: errChan,
|
errChan: errChan,
|
||||||
}:
|
}:
|
||||||
case <-n.quit:
|
case <-n.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case err = <-errChan:
|
case err = <-errChan:
|
||||||
case <-n.quit:
|
case <-n.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to update filter: %v", err)
|
return nil, fmt.Errorf("unable to update filter: %v", err)
|
||||||
|
@ -879,7 +872,7 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||||
select {
|
select {
|
||||||
case n.notificationRegistry <- dispatch:
|
case n.notificationRegistry <- dispatch:
|
||||||
case <-n.quit:
|
case <-n.quit:
|
||||||
return nil, ErrChainNotifierShuttingDown
|
return nil, chainntnfs.ErrChainNotifierShuttingDown
|
||||||
}
|
}
|
||||||
|
|
||||||
return ntfn.Event, nil
|
return ntfn.Event, nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue