mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 04:45:10 +02:00
[tracing] tracepoints to utxocache add, spent and uncache
Signed-off-by: Arnab Sen <arnabsen1729@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <consensus/consensus.h>
|
||||
#include <logging.h>
|
||||
#include <random.h>
|
||||
#include <util/trace.h>
|
||||
#include <version.h>
|
||||
|
||||
bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { return false; }
|
||||
@@ -95,6 +96,12 @@ void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possi
|
||||
it->second.coin = std::move(coin);
|
||||
it->second.flags |= CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0);
|
||||
cachedCoinsUsage += it->second.coin.DynamicMemoryUsage();
|
||||
TRACE5(utxocache, add,
|
||||
outpoint.hash.data(),
|
||||
(uint32_t)outpoint.n,
|
||||
(uint32_t)coin.nHeight,
|
||||
(int64_t)coin.out.nValue,
|
||||
(bool)coin.IsCoinBase());
|
||||
}
|
||||
|
||||
void CCoinsViewCache::EmplaceCoinInternalDANGER(COutPoint&& outpoint, Coin&& coin) {
|
||||
@@ -120,6 +127,12 @@ bool CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
|
||||
CCoinsMap::iterator it = FetchCoin(outpoint);
|
||||
if (it == cacheCoins.end()) return false;
|
||||
cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
|
||||
TRACE5(utxocache, spent,
|
||||
outpoint.hash.data(),
|
||||
(uint32_t)outpoint.n,
|
||||
(uint32_t)it->second.coin.nHeight,
|
||||
(int64_t)it->second.coin.out.nValue,
|
||||
(bool)it->second.coin.IsCoinBase());
|
||||
if (moveout) {
|
||||
*moveout = std::move(it->second.coin);
|
||||
}
|
||||
@@ -231,6 +244,12 @@ void CCoinsViewCache::Uncache(const COutPoint& hash)
|
||||
CCoinsMap::iterator it = cacheCoins.find(hash);
|
||||
if (it != cacheCoins.end() && it->second.flags == 0) {
|
||||
cachedCoinsUsage -= it->second.coin.DynamicMemoryUsage();
|
||||
TRACE5(utxocache, uncache,
|
||||
hash.hash.data(),
|
||||
(uint32_t)hash.n,
|
||||
(uint32_t)it->second.coin.nHeight,
|
||||
(int64_t)it->second.coin.out.nValue,
|
||||
(bool)it->second.coin.IsCoinBase());
|
||||
cacheCoins.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user