mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
Merge #13792: tx pool: Avoid passing redundant hash into addUnchecked (scripted-diff)
fa587773e5scripted-diff: Remove unused first argument to addUnchecked (MarcoFalke)fe5c49766ctx pool: Use the entry's hash instead of the one passed to addUnchecked (MarcoFalke)ddd395f968Mark CTxMemPoolEntry members that should not be modified const (MarcoFalke) Pull request description: Several years ago the transaction hash was not cached. For optimization the hash was instead passed into `addUnchecked` to avoid re-calculating it. Seef77654a0e9Passing in the hash is now redundant and the argument can safely be removed. Tree-SHA512: 0206b65c7a014295f67574120e8c5397bf1b1bd70c918ae1360ab093676f7f89a6f084fd2c7000a141baebfe63fe6f515559e38c4ac71810ba64f949f9c0467f
This commit is contained in:
@@ -20,13 +20,10 @@
|
||||
|
||||
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& _tx, const CAmount& _nFee,
|
||||
int64_t _nTime, unsigned int _entryHeight,
|
||||
bool _spendsCoinbase, int64_t _sigOpsCost, LockPoints lp):
|
||||
tx(_tx), nFee(_nFee), nTime(_nTime), entryHeight(_entryHeight),
|
||||
bool _spendsCoinbase, int64_t _sigOpsCost, LockPoints lp)
|
||||
: tx(_tx), nFee(_nFee), nTxWeight(GetTransactionWeight(*tx)), nUsageSize(RecursiveDynamicUsage(tx)), nTime(_nTime), entryHeight(_entryHeight),
|
||||
spendsCoinbase(_spendsCoinbase), sigOpCost(_sigOpsCost), lockPoints(lp)
|
||||
{
|
||||
nTxWeight = GetTransactionWeight(*tx);
|
||||
nUsageSize = RecursiveDynamicUsage(tx);
|
||||
|
||||
nCountWithDescendants = 1;
|
||||
nSizeWithDescendants = GetTxSize();
|
||||
nModFeesWithDescendants = nFee;
|
||||
@@ -355,7 +352,7 @@ void CTxMemPool::AddTransactionsUpdated(unsigned int n)
|
||||
nTransactionsUpdated += n;
|
||||
}
|
||||
|
||||
void CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
|
||||
void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
|
||||
{
|
||||
NotifyEntryAdded(entry.GetSharedTx());
|
||||
// Add to memory pool without checking anything.
|
||||
@@ -367,7 +364,7 @@ void CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
|
||||
// Update transaction for any feeDelta created by PrioritiseTransaction
|
||||
// TODO: refactor so that the fee delta is calculated before inserting
|
||||
// into mapTx.
|
||||
std::map<uint256, CAmount>::const_iterator pos = mapDeltas.find(hash);
|
||||
std::map<uint256, CAmount>::const_iterator pos = mapDeltas.find(entry.GetTx().GetHash());
|
||||
if (pos != mapDeltas.end()) {
|
||||
const CAmount &delta = pos->second;
|
||||
if (delta) {
|
||||
@@ -923,13 +920,13 @@ int CTxMemPool::Expire(int64_t time) {
|
||||
return stage.size();
|
||||
}
|
||||
|
||||
void CTxMemPool::addUnchecked(const uint256&hash, const CTxMemPoolEntry &entry, bool validFeeEstimate)
|
||||
void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, bool validFeeEstimate)
|
||||
{
|
||||
setEntries setAncestors;
|
||||
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
|
||||
std::string dummy;
|
||||
CalculateMemPoolAncestors(entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy);
|
||||
return addUnchecked(hash, entry, setAncestors, validFeeEstimate);
|
||||
return addUnchecked(entry, setAncestors, validFeeEstimate);
|
||||
}
|
||||
|
||||
void CTxMemPool::UpdateChild(txiter entry, txiter child, bool add)
|
||||
|
||||
Reference in New Issue
Block a user