refactor: move flags to private uint8_t and rename to m_flags

No behavior change. This prepares to add CCoinsCacheEntrys
to a doubly linked list when a flag is added.
This commit is contained in:
Andrew Toth 2024-06-28 16:44:25 -04:00
parent 4e4fb4cbab
commit f08faeade2
No known key found for this signature in database
GPG key ID: 60007AFC8938B018
2 changed files with 10 additions and 7 deletions

View file

@ -103,8 +103,11 @@ public:
*/ */
struct CCoinsCacheEntry struct CCoinsCacheEntry
{ {
private:
uint8_t m_flags{0};
public:
Coin coin; // The actual cached data. Coin coin; // The actual cached data.
unsigned char flags{0};
enum Flags { enum Flags {
/** /**
@ -130,14 +133,14 @@ struct CCoinsCacheEntry
CCoinsCacheEntry() noexcept = default; CCoinsCacheEntry() noexcept = default;
explicit CCoinsCacheEntry(Coin&& coin_) noexcept : coin(std::move(coin_)) {} explicit CCoinsCacheEntry(Coin&& coin_) noexcept : coin(std::move(coin_)) {}
inline void AddFlags(unsigned char flags) noexcept { this->flags |= flags; } inline void AddFlags(uint8_t flags) noexcept { m_flags |= flags; }
inline void ClearFlags() noexcept inline void ClearFlags() noexcept
{ {
flags = 0; m_flags = 0;
} }
inline unsigned char GetFlags() const noexcept { return flags; } inline uint8_t GetFlags() const noexcept { return m_flags; }
inline bool IsDirty() const noexcept { return flags & DIRTY; } inline bool IsDirty() const noexcept { return m_flags & DIRTY; }
inline bool IsFresh() const noexcept { return flags & FRESH; } inline bool IsFresh() const noexcept { return m_flags & FRESH; }
}; };
/** /**

View file

@ -125,7 +125,7 @@ FUZZ_TARGET(coins_view, .init = initialize_coins_view)
LIMITED_WHILE(good_data && fuzzed_data_provider.ConsumeBool(), 10'000) LIMITED_WHILE(good_data && fuzzed_data_provider.ConsumeBool(), 10'000)
{ {
CCoinsCacheEntry coins_cache_entry; CCoinsCacheEntry coins_cache_entry;
coins_cache_entry.AddFlags(fuzzed_data_provider.ConsumeIntegral<unsigned char>()); coins_cache_entry.AddFlags(fuzzed_data_provider.ConsumeIntegral<uint8_t>());
if (fuzzed_data_provider.ConsumeBool()) { if (fuzzed_data_provider.ConsumeBool()) {
coins_cache_entry.coin = random_coin; coins_cache_entry.coin = random_coin;
} else { } else {