mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-06 06:06:49 +00:00
[NOD-220] Fixed handleSearchRawTransactions trying to get confirmations of mempool transactions, which made txgen crash on start. (#351)
This commit is contained in:
parent
f0a675162c
commit
6acfa18d7c
@ -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() {
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user