Fix locking in GetTransaction.
GetTransaction needs to lock cs_main until ReadBlockFromDisk completes, the data inside CBlockIndex's can change since pruning. This lock was held by all calls to GetTransaction except rest_tx.
This commit is contained in:
parent
83f0e22497
commit
131c23d027
@ -954,14 +954,13 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
|
||||
{
|
||||
CBlockIndex *pindexSlow = NULL;
|
||||
{
|
||||
|
||||
LOCK(cs_main);
|
||||
{
|
||||
|
||||
if (mempool.lookup(hash, txOut))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fTxIndex) {
|
||||
CDiskTxPos postx;
|
||||
@ -995,7 +994,6 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
||||
if (nHeight > 0)
|
||||
pindexSlow = chainActive[nHeight];
|
||||
}
|
||||
}
|
||||
|
||||
if (pindexSlow) {
|
||||
CBlock block;
|
||||
|
Loading…
Reference in New Issue
Block a user