mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 18:09:47 +01:00
refactor: disallow setting flags in CCoinsCacheEntry constructors
No behavior change because any entries that are added in EmplaceCoinInternalDANGER have DIRTY assigned to them after, and if they are not inserted then they will not be modified as before. This prepares moving the cache entry flags field to private access. Co-Authored-By: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
This commit is contained in:
parent
8737c0cefa
commit
4e4fb4cbab
@ -108,10 +108,13 @@ void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possi
|
||||
|
||||
void CCoinsViewCache::EmplaceCoinInternalDANGER(COutPoint&& outpoint, Coin&& coin) {
|
||||
cachedCoinsUsage += coin.DynamicMemoryUsage();
|
||||
cacheCoins.emplace(
|
||||
auto [it, inserted] = cacheCoins.emplace(
|
||||
std::piecewise_construct,
|
||||
std::forward_as_tuple(std::move(outpoint)),
|
||||
std::forward_as_tuple(std::move(coin), CCoinsCacheEntry::DIRTY));
|
||||
std::forward_as_tuple(std::move(coin)));
|
||||
if (inserted) {
|
||||
it->second.AddFlags(CCoinsCacheEntry::DIRTY);
|
||||
}
|
||||
}
|
||||
|
||||
void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight, bool check_for_overwrite) {
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
struct CCoinsCacheEntry
|
||||
{
|
||||
Coin coin; // The actual cached data.
|
||||
unsigned char flags;
|
||||
unsigned char flags{0};
|
||||
|
||||
enum Flags {
|
||||
/**
|
||||
@ -127,9 +127,8 @@ struct CCoinsCacheEntry
|
||||
FRESH = (1 << 1),
|
||||
};
|
||||
|
||||
CCoinsCacheEntry() : flags(0) {}
|
||||
explicit CCoinsCacheEntry(Coin&& coin_) : coin(std::move(coin_)), flags(0) {}
|
||||
CCoinsCacheEntry(Coin&& coin_, unsigned char flag) : coin(std::move(coin_)), flags(flag) {}
|
||||
CCoinsCacheEntry() noexcept = default;
|
||||
explicit CCoinsCacheEntry(Coin&& coin_) noexcept : coin(std::move(coin_)) {}
|
||||
|
||||
inline void AddFlags(unsigned char flags) noexcept { this->flags |= flags; }
|
||||
inline void ClearFlags() noexcept
|
||||
|
Loading…
Reference in New Issue
Block a user