Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.cpp
Show All 23 Lines | |||||
#include <validation.h> | #include <validation.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
#include <version.h> | #include <version.h> | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <cmath> | #include <cmath> | ||||
#include <limits> | #include <limits> | ||||
// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index. | |||||
// Remove after Wellington | |||||
struct update_descendant_state { | |||||
update_descendant_state(int64_t _modifySize, Amount _modifyFee, | |||||
int64_t _modifyCount, int64_t _modifySigChecks) | |||||
: modifySize(_modifySize), modifyFee(_modifyFee), | |||||
modifyCount(_modifyCount), modifySigChecks(_modifySigChecks) {} | |||||
void operator()(CTxMemPoolEntry &e) { | |||||
e.UpdateDescendantState(modifySize, modifyFee, modifyCount, | |||||
modifySigChecks); | |||||
} | |||||
private: | |||||
int64_t modifySize; | |||||
Amount modifyFee; | |||||
int64_t modifyCount; | |||||
int64_t modifySigChecks; | |||||
}; | |||||
struct update_ancestor_state { | |||||
update_ancestor_state(int64_t _modifySize, Amount _modifyFee, | |||||
int64_t _modifyCount, int64_t _modifySigChecks) | |||||
: modifySize(_modifySize), modifyFee(_modifyFee), | |||||
modifyCount(_modifyCount), modifySigChecks(_modifySigChecks) {} | |||||
void operator()(CTxMemPoolEntry &e) { | |||||
e.UpdateAncestorState(modifySize, modifyFee, modifyCount, | |||||
modifySigChecks); | |||||
} | |||||
private: | |||||
int64_t modifySize; | |||||
Amount modifyFee; | |||||
int64_t modifyCount; | |||||
int64_t modifySigChecks; | |||||
}; | |||||
bool TestLockPointValidity(const CChain &active_chain, const LockPoints &lp) { | bool TestLockPointValidity(const CChain &active_chain, const LockPoints &lp) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
// If there are relative lock times then the maxInputBlock will be set | // If there are relative lock times then the maxInputBlock will be set | ||||
// If there are no relative lock times, the LockPoints don't depend on the | // If there are no relative lock times, the LockPoints don't depend on the | ||||
// chain | // chain | ||||
if (lp.maxInputBlock) { | if (lp.maxInputBlock) { | ||||
// Check whether active_chain is an extension of the block at which the | // Check whether active_chain is an extension of the block at which the | ||||
// LockPoints calculation was valid. If not LockPoints are no longer | // LockPoints calculation was valid. If not LockPoints are no longer | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, | ||||
// each transaction being removed and any mempool children (ie, update | // each transaction being removed and any mempool children (ie, update | ||||
// CTxMemPoolEntry::m_parents for each direct child of a transaction being | // CTxMemPoolEntry::m_parents for each direct child of a transaction being | ||||
// removed). | // removed). | ||||
for (txiter removeIt : entriesToRemove) { | for (txiter removeIt : entriesToRemove) { | ||||
UpdateChildrenForRemoval(removeIt); | UpdateChildrenForRemoval(removeIt); | ||||
} | } | ||||
} | } | ||||
void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, | |||||
Amount modifyFee, | |||||
int64_t modifyCount, | |||||
int64_t modifySigChecks) { | |||||
nSizeWithDescendants += modifySize; | |||||
assert(int64_t(nSizeWithDescendants) > 0); | |||||
nModFeesWithDescendants += modifyFee; | |||||
nCountWithDescendants += modifyCount; | |||||
assert(int64_t(nCountWithDescendants) > 0); | |||||
nSigChecksWithDescendants += modifySigChecks; | |||||
assert(nSigChecksWithDescendants >= 0); | |||||
} | |||||
void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, Amount modifyFee, | |||||
int64_t modifyCount, | |||||
int64_t modifySigChecks) { | |||||
nSizeWithAncestors += modifySize; | |||||
assert(int64_t(nSizeWithAncestors) > 0); | |||||
nModFeesWithAncestors += modifyFee; | |||||
nCountWithAncestors += modifyCount; | |||||
assert(int64_t(nCountWithAncestors) > 0); | |||||
nSigChecksWithAncestors += modifySigChecks; | |||||
assert(nSigChecksWithAncestors >= 0); | |||||
} | |||||
CTxMemPool::CTxMemPool(int check_ratio) : m_check_ratio(check_ratio) { | CTxMemPool::CTxMemPool(int check_ratio) : m_check_ratio(check_ratio) { | ||||
// lock free clear | // lock free clear | ||||
_clear(); | _clear(); | ||||
} | } | ||||
CTxMemPool::~CTxMemPool() {} | CTxMemPool::~CTxMemPool() {} | ||||
bool CTxMemPool::isSpent(const COutPoint &outpoint) const { | bool CTxMemPool::isSpent(const COutPoint &outpoint) const { | ||||
▲ Show 20 Lines • Show All 873 Lines • Show Last 20 Lines |