From f08faeade2f99ae1de6f3c481697541cc16186c7 Mon Sep 17 00:00:00 2001 From: Andrew Toth Date: Fri, 28 Jun 2024 16:44:25 -0400 Subject: [PATCH] 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. --- src/coins.h | 15 +++++++++------ src/test/fuzz/coins_view.cpp | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/coins.h b/src/coins.h index bb1c17a887..22b01901e6 100644 --- a/src/coins.h +++ b/src/coins.h @@ -103,8 +103,11 @@ public: */ struct CCoinsCacheEntry { +private: + uint8_t m_flags{0}; + +public: Coin coin; // The actual cached data. - unsigned char flags{0}; enum Flags { /** @@ -130,14 +133,14 @@ struct CCoinsCacheEntry CCoinsCacheEntry() noexcept = default; 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 { - flags = 0; + m_flags = 0; } - inline unsigned char GetFlags() const noexcept { return flags; } - inline bool IsDirty() const noexcept { return flags & DIRTY; } - inline bool IsFresh() const noexcept { return flags & FRESH; } + inline uint8_t GetFlags() const noexcept { return m_flags; } + inline bool IsDirty() const noexcept { return m_flags & DIRTY; } + inline bool IsFresh() const noexcept { return m_flags & FRESH; } }; /** diff --git a/src/test/fuzz/coins_view.cpp b/src/test/fuzz/coins_view.cpp index 5f942eba67..1f24d78dca 100644 --- a/src/test/fuzz/coins_view.cpp +++ b/src/test/fuzz/coins_view.cpp @@ -125,7 +125,7 @@ FUZZ_TARGET(coins_view, .init = initialize_coins_view) LIMITED_WHILE(good_data && fuzzed_data_provider.ConsumeBool(), 10'000) { CCoinsCacheEntry coins_cache_entry; - coins_cache_entry.AddFlags(fuzzed_data_provider.ConsumeIntegral()); + coins_cache_entry.AddFlags(fuzzed_data_provider.ConsumeIntegral()); if (fuzzed_data_provider.ConsumeBool()) { coins_cache_entry.coin = random_coin; } else {