Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.cpp
Show First 20 Lines • Show All 402 Lines • ▼ Show 20 Lines | unsigned int CTxMemPool::GetTransactionsUpdated() const { | ||||
return nTransactionsUpdated; | return nTransactionsUpdated; | ||||
} | } | ||||
void CTxMemPool::AddTransactionsUpdated(unsigned int n) { | void CTxMemPool::AddTransactionsUpdated(unsigned int n) { | ||||
LOCK(cs); | LOCK(cs); | ||||
nTransactionsUpdated += n; | nTransactionsUpdated += n; | ||||
} | } | ||||
void CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, | void CTxMemPool::addUnchecked(const TxId &txid, const CTxMemPoolEntry &entry, | ||||
setEntries &setAncestors) { | setEntries &setAncestors) { | ||||
NotifyEntryAdded(entry.GetSharedTx()); | NotifyEntryAdded(entry.GetSharedTx()); | ||||
// Add to memory pool without checking anything. | // Add to memory pool without checking anything. | ||||
// Used by AcceptToMemoryPool(), which DOES do all the appropriate checks. | // Used by AcceptToMemoryPool(), which DOES do all the appropriate checks. | ||||
indexed_transaction_set::iterator newit = mapTx.insert(entry).first; | indexed_transaction_set::iterator newit = mapTx.insert(entry).first; | ||||
mapLinks.insert(make_pair(newit, TxLinks())); | mapLinks.insert(make_pair(newit, TxLinks())); | ||||
// Update transaction for any feeDelta created by PrioritiseTransaction | // Update transaction for any feeDelta created by PrioritiseTransaction | ||||
// TODO: refactor so that the fee delta is calculated before inserting into | // TODO: refactor so that the fee delta is calculated before inserting into | ||||
// mapTx. | // mapTx. | ||||
std::map<uint256, TXModifier>::const_iterator pos = mapDeltas.find(hash); | std::map<TxId, TXModifier>::const_iterator pos = mapDeltas.find(txid); | ||||
if (pos != mapDeltas.end()) { | if (pos != mapDeltas.end()) { | ||||
const TXModifier &deltas = pos->second; | const TXModifier &deltas = pos->second; | ||||
if (deltas.second != Amount::zero()) { | if (deltas.second != Amount::zero()) { | ||||
mapTx.modify(newit, update_fee_delta(deltas.second)); | mapTx.modify(newit, update_fee_delta(deltas.second)); | ||||
} | } | ||||
} | } | ||||
// Update cachedInnerUsage to include contained transaction's usage. | // Update cachedInnerUsage to include contained transaction's usage. | ||||
▲ Show 20 Lines • Show All 534 Lines • ▼ Show 20 Lines | void CTxMemPool::PrioritiseTransaction(const TxId &txid, double dPriorityDelta, | ||||
} | } | ||||
++nTransactionsUpdated; | ++nTransactionsUpdated; | ||||
} | } | ||||
} | } | ||||
LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", | LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", | ||||
txid.ToString(), dPriorityDelta, FormatMoney(nFeeDelta)); | txid.ToString(), dPriorityDelta, FormatMoney(nFeeDelta)); | ||||
} | } | ||||
void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, | void CTxMemPool::ApplyDeltas(const TxId &txid, double &dPriorityDelta, | ||||
Amount &nFeeDelta) const { | Amount &nFeeDelta) const { | ||||
LOCK(cs); | LOCK(cs); | ||||
std::map<uint256, TXModifier>::const_iterator pos = mapDeltas.find(hash); | std::map<TxId, TXModifier>::const_iterator pos = mapDeltas.find(txid); | ||||
if (pos == mapDeltas.end()) { | if (pos == mapDeltas.end()) { | ||||
return; | return; | ||||
} | } | ||||
const TXModifier &deltas = pos->second; | const TXModifier &deltas = pos->second; | ||||
dPriorityDelta += deltas.first; | dPriorityDelta += deltas.first; | ||||
nFeeDelta += deltas.second; | nFeeDelta += deltas.second; | ||||
} | } | ||||
void CTxMemPool::ClearPrioritisation(const uint256 hash) { | void CTxMemPool::ClearPrioritisation(const TxId &txid) { | ||||
LOCK(cs); | LOCK(cs); | ||||
mapDeltas.erase(hash); | mapDeltas.erase(txid); | ||||
} | } | ||||
bool CTxMemPool::HasNoInputsOf(const CTransaction &tx) const { | bool CTxMemPool::HasNoInputsOf(const CTransaction &tx) const { | ||||
for (const CTxIn &in : tx.vin) { | for (const CTxIn &in : tx.vin) { | ||||
if (exists(in.prevout.GetTxId())) { | if (exists(in.prevout.GetTxId())) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | void CTxMemPool::LimitSize(size_t limit, unsigned long age) { | ||||
std::vector<COutPoint> vNoSpendsRemaining; | std::vector<COutPoint> vNoSpendsRemaining; | ||||
TrimToSize(limit, &vNoSpendsRemaining); | TrimToSize(limit, &vNoSpendsRemaining); | ||||
for (const COutPoint &removed : vNoSpendsRemaining) { | for (const COutPoint &removed : vNoSpendsRemaining) { | ||||
pcoinsTip->Uncache(removed); | pcoinsTip->Uncache(removed); | ||||
} | } | ||||
} | } | ||||
void CTxMemPool::addUnchecked(const uint256 &hash, | void CTxMemPool::addUnchecked(const TxId &txid, const CTxMemPoolEntry &entry) { | ||||
const CTxMemPoolEntry &entry) { | |||||
setEntries setAncestors; | setEntries setAncestors; | ||||
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max(); | uint64_t nNoLimit = std::numeric_limits<uint64_t>::max(); | ||||
std::string dummy; | std::string dummy; | ||||
CalculateMemPoolAncestors(entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, | CalculateMemPoolAncestors(entry, setAncestors, nNoLimit, nNoLimit, nNoLimit, | ||||
nNoLimit, dummy); | nNoLimit, dummy); | ||||
return addUnchecked(hash, entry, setAncestors); | return addUnchecked(txid, entry, setAncestors); | ||||
} | } | ||||
void CTxMemPool::UpdateChild(txiter entry, txiter child, bool add) { | void CTxMemPool::UpdateChild(txiter entry, txiter child, bool add) { | ||||
setEntries s; | setEntries s; | ||||
if (add && mapLinks[entry].children.insert(child).second) { | if (add && mapLinks[entry].children.insert(child).second) { | ||||
cachedInnerUsage += memusage::IncrementalDynamicUsage(s); | cachedInnerUsage += memusage::IncrementalDynamicUsage(s); | ||||
} else if (!add && mapLinks[entry].children.erase(child)) { | } else if (!add && mapLinks[entry].children.erase(child)) { | ||||
cachedInnerUsage -= memusage::IncrementalDynamicUsage(s); | cachedInnerUsage -= memusage::IncrementalDynamicUsage(s); | ||||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |