mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
CTxMemPool: eliminate redundant lock, GetHash() call
::addUnchecked()'s only caller already takes the necessary lock, and has already calculated the TX's hash.
This commit is contained in:
parent
96929a5515
commit
f77654a0e9
@ -600,7 +600,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs,
|
|||||||
printf("CTxMemPool::accept() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str());
|
printf("CTxMemPool::accept() : replacing tx %s with new version\n", ptxOld->GetHash().ToString().c_str());
|
||||||
remove(*ptxOld);
|
remove(*ptxOld);
|
||||||
}
|
}
|
||||||
addUnchecked(tx);
|
addUnchecked(hash, tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
///// are we sure this is ok when loading transactions or restoring block txes
|
///// are we sure this is ok when loading transactions or restoring block txes
|
||||||
@ -619,13 +619,11 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi
|
|||||||
return mempool.accept(txdb, *this, fCheckInputs, pfMissingInputs);
|
return mempool.accept(txdb, *this, fCheckInputs, pfMissingInputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTxMemPool::addUnchecked(CTransaction &tx)
|
bool CTxMemPool::addUnchecked(const uint256& hash, CTransaction &tx)
|
||||||
{
|
{
|
||||||
// Add to memory pool without checking anything. Don't call this directly,
|
// Add to memory pool without checking anything. Don't call this directly,
|
||||||
// call CTxMemPool::accept to properly check the transaction first.
|
// call CTxMemPool::accept to properly check the transaction first.
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
|
||||||
uint256 hash = tx.GetHash();
|
|
||||||
mapTx[hash] = tx;
|
mapTx[hash] = tx;
|
||||||
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
for (unsigned int i = 0; i < tx.vin.size(); i++)
|
||||||
mapNextTx[tx.vin[i].prevout] = CInPoint(&mapTx[hash], i);
|
mapNextTx[tx.vin[i].prevout] = CInPoint(&mapTx[hash], i);
|
||||||
|
@ -1602,7 +1602,7 @@ public:
|
|||||||
|
|
||||||
bool accept(CTxDB& txdb, CTransaction &tx,
|
bool accept(CTxDB& txdb, CTransaction &tx,
|
||||||
bool fCheckInputs, bool* pfMissingInputs);
|
bool fCheckInputs, bool* pfMissingInputs);
|
||||||
bool addUnchecked(CTransaction &tx);
|
bool addUnchecked(const uint256& hash, CTransaction &tx);
|
||||||
bool remove(CTransaction &tx);
|
bool remove(CTransaction &tx);
|
||||||
void queryHashes(std::vector<uint256>& vtxid);
|
void queryHashes(std::vector<uint256>& vtxid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user