Changeset View
Changeset View
Standalone View
Standalone View
src/txmempool.cpp
Show First 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | bool CTxMemPool::addUnchecked(const uint256 &hash, const CTxMemPoolEntry &entry, | ||||
// Used by AcceptToMemoryPool(), which DOES do all the appropriate checks. | // Used by AcceptToMemoryPool(), which DOES do all the appropriate checks. | ||||
LOCK(cs); | LOCK(cs); | ||||
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, std::pair<double, Amount>>::const_iterator pos = | std::map<uint256, TXModifier>::const_iterator pos = mapDeltas.find(hash); | ||||
mapDeltas.find(hash); | |||||
if (pos != mapDeltas.end()) { | if (pos != mapDeltas.end()) { | ||||
const std::pair<double, Amount> &deltas = pos->second; | const TXModifier &deltas = pos->second; | ||||
if (deltas.second != Amount(0)) { | if (deltas.second != Amount(0)) { | ||||
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. | ||||
// (When we update the entry for in-mempool parents, memory usage will be | // (When we update the entry for in-mempool parents, memory usage will be | ||||
// further updated.) | // further updated.) | ||||
▲ Show 20 Lines • Show All 541 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CTxMemPool::PrioritiseTransaction(const uint256 hash, | void CTxMemPool::PrioritiseTransaction(const uint256 hash, | ||||
const std::string strHash, | const std::string strHash, | ||||
double dPriorityDelta, | double dPriorityDelta, | ||||
const Amount nFeeDelta) { | const Amount nFeeDelta) { | ||||
{ | { | ||||
LOCK(cs); | LOCK(cs); | ||||
std::pair<double, Amount> &deltas = mapDeltas[hash]; | TXModifier &deltas = mapDeltas[hash]; | ||||
deltas.first += dPriorityDelta; | deltas.first += dPriorityDelta; | ||||
deltas.second += nFeeDelta; | deltas.second += nFeeDelta; | ||||
txiter it = mapTx.find(hash); | txiter it = mapTx.find(hash); | ||||
if (it != mapTx.end()) { | if (it != mapTx.end()) { | ||||
mapTx.modify(it, update_fee_delta(deltas.second)); | mapTx.modify(it, update_fee_delta(deltas.second)); | ||||
// Now update all ancestors' modified fees with descendants | // Now update all ancestors' modified fees with descendants | ||||
setEntries setAncestors; | setEntries setAncestors; | ||||
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max(); | uint64_t nNoLimit = std::numeric_limits<uint64_t>::max(); | ||||
Show All 17 Lines | void CTxMemPool::PrioritiseTransaction(const uint256 hash, | ||||
} | } | ||||
LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, | LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, | ||||
dPriorityDelta, FormatMoney(nFeeDelta)); | dPriorityDelta, FormatMoney(nFeeDelta)); | ||||
} | } | ||||
void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, | void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, | ||||
Amount &nFeeDelta) const { | Amount &nFeeDelta) const { | ||||
LOCK(cs); | LOCK(cs); | ||||
std::map<uint256, std::pair<double, Amount>>::const_iterator pos = | std::map<uint256, TXModifier>::const_iterator pos = mapDeltas.find(hash); | ||||
mapDeltas.find(hash); | |||||
if (pos == mapDeltas.end()) { | if (pos == mapDeltas.end()) { | ||||
return; | return; | ||||
} | } | ||||
const std::pair<double, Amount> &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 uint256 hash) { | ||||
LOCK(cs); | LOCK(cs); | ||||
mapDeltas.erase(hash); | mapDeltas.erase(hash); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |