diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index 10551e57..6675207b 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -26,11 +26,6 @@ const ( ) 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 // transaction by manually scanning the chain within a specific range // 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 "+ "historical dispatch: %v", rawTxRes.BlockHash, err) } - block, err := b.chainConn.GetBlockVerbose(blockHash) if err != nil { return nil, chainntnfs.TxNotFoundIndex, @@ -559,7 +553,7 @@ func (b *BitcoindNotifier) confDetailsManually(confRequest chainntnfs.ConfReques select { case <-b.quit: return nil, chainntnfs.TxNotFoundManually, - ErrChainNotifierShuttingDown + chainntnfs.ErrChainNotifierShuttingDown default: } @@ -728,7 +722,7 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, select { case b.notificationRegistry <- historicalDispatch: case <-b.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } return ntfn.Event, nil @@ -805,7 +799,7 @@ func (b *BitcoindNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, select { case b.notificationRegistry <- historicalDispatch: case <-b.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } return ntfn.Event, nil @@ -829,7 +823,7 @@ func (b *BitcoindNotifier) dispatchSpendDetailsManually( // processing the next height. select { case <-b.quit: - return ErrChainNotifierShuttingDown + return chainntnfs.ErrChainNotifierShuttingDown default: } @@ -923,7 +917,7 @@ func (b *BitcoindNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, case b.notificationRegistry <- dispatch: return ntfn.Event, nil case <-b.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } } diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 1486f18b..4f432dbc 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -26,13 +26,6 @@ const ( 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 // used as an element within an unbounded queue in order to avoid blocking the // main rpc dispatch rule. @@ -610,7 +603,7 @@ func (b *BtcdNotifier) confDetailsManually(confRequest chainntnfs.ConfRequest, select { case <-b.quit: return nil, chainntnfs.TxNotFoundManually, - ErrChainNotifierShuttingDown + chainntnfs.ErrChainNotifierShuttingDown default: } @@ -964,7 +957,7 @@ func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, case b.notificationRegistry <- dispatch: return ntfn.Event, nil case <-b.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } } diff --git a/chainntnfs/interface.go b/chainntnfs/interface.go index 13b49471..b03d9973 100644 --- a/chainntnfs/interface.go +++ b/chainntnfs/interface.go @@ -1,6 +1,7 @@ package chainntnfs import ( + "errors" "fmt" "sync" @@ -9,6 +10,12 @@ import ( "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. type TxConfStatus uint8 diff --git a/chainntnfs/neutrinonotify/neutrino.go b/chainntnfs/neutrinonotify/neutrino.go index b63dee0c..6a1eafa9 100644 --- a/chainntnfs/neutrinonotify/neutrino.go +++ b/chainntnfs/neutrinonotify/neutrino.go @@ -27,13 +27,6 @@ const ( 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 // Bitcoin light client. Unlike other implementations, this implementation // 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. select { case <-n.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown default: } @@ -710,13 +703,13 @@ func (n *NeutrinoNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint, errChan: errChan, }: case <-n.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } select { case err = <-errChan: case <-n.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } if err != nil { return nil, fmt.Errorf("unable to update filter: %v", err) @@ -856,13 +849,13 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, errChan: errChan, }: case <-n.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } select { case err = <-errChan: case <-n.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } if err != nil { return nil, fmt.Errorf("unable to update filter: %v", err) @@ -879,7 +872,7 @@ func (n *NeutrinoNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash, select { case n.notificationRegistry <- dispatch: case <-n.quit: - return nil, ErrChainNotifierShuttingDown + return nil, chainntnfs.ErrChainNotifierShuttingDown } return ntfn.Event, nil