[NOD-220] Fixed handleSearchRawTransactions trying to get confirmations of mempool transactions, which made txgen crash on start. (#351)

This commit is contained in:
stasatdaglabs 2019-07-28 13:02:16 +03:00 committed by Svarog
parent f0a675162c
commit 6acfa18d7c
2 changed files with 8 additions and 8 deletions

View File

@ -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() {

View File

@ -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