diff options
author | glozow <gloriajzhao@gmail.com> | 2023-04-16 08:49:24 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2023-05-10 21:10:44 +0100 |
commit | 67b7fecacd0489809690982c89ba2d0acdca938c (patch) | |
tree | 6a8526132e59274abbca9dd973ad62dc19ce2d84 /src/txmempool.cpp | |
parent | c1061acb9d502cdf8c6996c818d9a8a281cbe40c (diff) |
[mempool] clear mapDeltas entry if prioritisetransaction sets delta to 0
It's unnecessary to keep the data around, as it doesn't do anything. If
prioritisetransaction is called again, we'll make a new entry in
mapDeltas.
These entries are only deleted when the transaction is mined or conflicted
from a block (i.e. not in replacement or eviction), are persisted in
mempool.dat, and never expire. If node operators use the RPC to
regularly prioritise/de-prioritise transactions, these (meaningless)
map entries may hang around forever and take up valuable mempool memory.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 0d85d1d135..7a7abe2d1c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -870,8 +870,17 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD } ++nTransactionsUpdated; } + if (delta == 0) { + mapDeltas.erase(hash); + LogPrintf("PrioritiseTransaction: %s (%sin mempool) delta cleared\n", hash.ToString(), it == mapTx.end() ? "not " : ""); + } else { + LogPrintf("PrioritiseTransaction: %s (%sin mempool) fee += %s, new delta=%s\n", + hash.ToString(), + it == mapTx.end() ? "not " : "", + FormatMoney(nFeeDelta), + FormatMoney(delta)); + } } - LogPrintf("PrioritiseTransaction: %s fee += %s\n", hash.ToString(), FormatMoney(nFeeDelta)); } void CTxMemPool::ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const |