From f82fd5fe86091e5ee73ba9da4d5508705cf0db42 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 24 Aug 2018 14:45:12 +0200 Subject: [PATCH] chainntnfs/bitcoind: fallback to scan manually only in case of err != nil --- chainntnfs/bitcoindnotify/bitcoind.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/chainntnfs/bitcoindnotify/bitcoind.go b/chainntnfs/bitcoindnotify/bitcoind.go index a5d630a2b..82abfd984 100644 --- a/chainntnfs/bitcoindnotify/bitcoind.go +++ b/chainntnfs/bitcoindnotify/bitcoind.go @@ -458,6 +458,14 @@ func (b *BitcoindNotifier) historicalConfDetails(txid *chainhash.Hash, // We'll then check the status of the transaction lookup returned to // determine whether we should proceed with any fallback methods. switch { + + // We failed querying the index for the transaction, fall back to + // scanning manually. + case err != nil: + chainntnfs.Log.Debugf("Failed getting conf details from "+ + "index (%v), scanning manually", err) + return b.confDetailsManually(txid, heightHint, currentHeight) + // The transaction was found within the node's mempool. case txStatus == chainntnfs.TxFoundMempool: @@ -465,12 +473,12 @@ func (b *BitcoindNotifier) historicalConfDetails(txid *chainhash.Hash, case txStatus == chainntnfs.TxFoundIndex: // The transaction was not found within the node's mempool or txindex. - case err == nil && txStatus == chainntnfs.TxNotFoundIndex: + case txStatus == chainntnfs.TxNotFoundIndex: - // We failed to look up the transaction within the node's mempool or - // txindex, so we'll proceed to scan the chain manually. + // Unexpected txStatus returned. default: - return b.confDetailsManually(txid, heightHint, currentHeight) + return nil, txStatus, + fmt.Errorf("Got unexpected txConfStatus: %v", txStatus) } return txConf, txStatus, nil