chainntnfs/multi: replace txid with ConfRequest in txindex matching

This commit is contained in:
Conner Fromknecht 2019-06-27 19:10:34 -07:00
parent 922a980bd7
commit e10d4e9047
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
3 changed files with 8 additions and 7 deletions

@ -457,7 +457,7 @@ func (b *BitcoindNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequ
// txindex. // txindex.
txNotFoundErr := "No such mempool or blockchain transaction" txNotFoundErr := "No such mempool or blockchain transaction"
txConf, txStatus, err := chainntnfs.ConfDetailsFromTxIndex( txConf, txStatus, err := chainntnfs.ConfDetailsFromTxIndex(
b.chainConn, &confRequest.TxID, txNotFoundErr, b.chainConn, confRequest, txNotFoundErr,
) )
// We'll then check the status of the transaction lookup returned to // We'll then check the status of the transaction lookup returned to

@ -479,7 +479,7 @@ func (b *BtcdNotifier) historicalConfDetails(confRequest chainntnfs.ConfRequest,
// txindex. // txindex.
txNotFoundErr := "No information available about transaction" txNotFoundErr := "No information available about transaction"
txConf, txStatus, err := chainntnfs.ConfDetailsFromTxIndex( txConf, txStatus, err := chainntnfs.ConfDetailsFromTxIndex(
b.chainConn, &confRequest.TxID, txNotFoundErr, b.chainConn, confRequest, txNotFoundErr,
) )
// We'll then check the status of the transaction lookup returned to // We'll then check the status of the transaction lookup returned to

@ -605,12 +605,12 @@ type TxIndexConn interface {
// the mempool this will be TxFoundMempool, if it is found in a block this will // the mempool this will be TxFoundMempool, if it is found in a block this will
// be TxFoundIndex. Otherwise TxNotFoundIndex is returned. If the tx is found // be TxFoundIndex. Otherwise TxNotFoundIndex is returned. If the tx is found
// in a block its confirmation details are also returned. // in a block its confirmation details are also returned.
func ConfDetailsFromTxIndex(chainConn TxIndexConn, txid *chainhash.Hash, func ConfDetailsFromTxIndex(chainConn TxIndexConn, r ConfRequest,
txNotFoundErr string) (*TxConfirmation, TxConfStatus, error) { txNotFoundErr string) (*TxConfirmation, TxConfStatus, error) {
// If the transaction has some or all of its confirmations required, // If the transaction has some or all of its confirmations required,
// then we may be able to dispatch it immediately. // then we may be able to dispatch it immediately.
rawTxRes, err := chainConn.GetRawTransactionVerbose(txid) rawTxRes, err := chainConn.GetRawTransactionVerbose(&r.TxID)
if err != nil { if err != nil {
// If the transaction lookup was successful, but it wasn't found // If the transaction lookup was successful, but it wasn't found
// within the index itself, then we can exit early. We'll also // within the index itself, then we can exit early. We'll also
@ -624,7 +624,8 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, txid *chainhash.Hash,
} }
return nil, TxNotFoundIndex, return nil, TxNotFoundIndex,
fmt.Errorf("unable to query for txid %v: %v", txid, err) fmt.Errorf("unable to query for txid %v: %v",
r.TxID, err)
} }
// Make sure we actually retrieved a transaction that is included in a // Make sure we actually retrieved a transaction that is included in a
@ -652,7 +653,7 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, txid *chainhash.Hash,
// If the block was obtained, locate the transaction's index within the // If the block was obtained, locate the transaction's index within the
// block so we can give the subscriber full confirmation details. // block so we can give the subscriber full confirmation details.
txidStr := txid.String() txidStr := r.TxID.String()
for txIndex, txHash := range block.Tx { for txIndex, txHash := range block.Tx {
if txHash != txidStr { if txHash != txidStr {
continue continue
@ -684,5 +685,5 @@ func ConfDetailsFromTxIndex(chainConn TxIndexConn, txid *chainhash.Hash,
// We return an error because we should have found the transaction // We return an error because we should have found the transaction
// within the block, but didn't. // within the block, but didn't.
return nil, TxNotFoundIndex, fmt.Errorf("unable to locate "+ return nil, TxNotFoundIndex, fmt.Errorf("unable to locate "+
"tx %v in block %v", txid, blockHash) "tx %v in block %v", r.TxID, blockHash)
} }