From 6acfa18d7c2ba03a8c4d71c4bd0ae490a03bdf00 Mon Sep 17 00:00:00 2001 From: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com> Date: Sun, 28 Jul 2019 13:02:16 +0300 Subject: [PATCH] [NOD-220] Fixed handleSearchRawTransactions trying to get confirmations of mempool transactions, which made txgen crash on start. (#351) --- blockdag/indexers/txindex.go | 8 ++++---- server/rpc/rpcserver.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/blockdag/indexers/txindex.go b/blockdag/indexers/txindex.go index ee4cd4d36..5d9e4169d 100644 --- a/blockdag/indexers/txindex.go +++ b/blockdag/indexers/txindex.go @@ -544,16 +544,16 @@ func dbFetchTxAcceptingBlock(dbTx database.Tx, txID *daghash.TxID, dag *blockdag if bucket == nil { return nil, database.Error{ ErrorCode: database.ErrCorruption, - Description: fmt.Sprintf("No accepting blocks "+ - "were found for %s", txID), + Description: fmt.Sprintf("No accepting blocks bucket "+ + "exists for %s", txID), } } cursor := bucket.Cursor() if !cursor.First() { return nil, database.Error{ ErrorCode: database.ErrCorruption, - Description: fmt.Sprintf("No accepting blocks "+ - "were found for %s", txID), + Description: fmt.Sprintf("Accepting blocks bucket is "+ + "empty for %s", txID), } } for ; cursor.Key() != nil; cursor.Next() { diff --git a/server/rpc/rpcserver.go b/server/rpc/rpcserver.go index d016d8f2a..5db6a7951 100644 --- a/server/rpc/rpcserver.go +++ b/server/rpc/rpcserver.go @@ -3303,7 +3303,10 @@ func handleSearchRawTransactions(s *Server, cmd interface{}, closeChan <-chan st result.BlockHash = blkHashStr } - if s.cfg.TxIndex != nil { + // rtx.tx is only set when the transaction was retrieved from the mempool + result.IsInMempool = rtx.tx != nil + + if s.cfg.TxIndex != nil && !result.IsInMempool { confirmations, err := txConfirmations(s, mtx.TxID()) if err != nil { context := "Failed to obtain block confirmations" @@ -3311,9 +3314,6 @@ func handleSearchRawTransactions(s *Server, cmd interface{}, closeChan <-chan st } result.Confirmations = &confirmations } - - // rtx.tx is only set when the transaction was retrieved from the mempool - result.IsInMempool = rtx.tx != nil } return srtList, nil