Skip to content

Commit f08faea

Browse files
committed
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.
1 parent 4e4fb4c commit f08faea

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/coins.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ class Coin
103103
*/
104104
struct CCoinsCacheEntry
105105
{
106+
private:
107+
uint8_t m_flags{0};
108+
109+
public:
106110
Coin coin; // The actual cached data.
107-
unsigned char flags{0};
108111

109112
enum Flags {
110113
/**
@@ -130,14 +133,14 @@ struct CCoinsCacheEntry
130133
CCoinsCacheEntry() noexcept = default;
131134
explicit CCoinsCacheEntry(Coin&& coin_) noexcept : coin(std::move(coin_)) {}
132135

133-
inline void AddFlags(unsigned char flags) noexcept { this->flags |= flags; }
136+
inline void AddFlags(uint8_t flags) noexcept { m_flags |= flags; }
134137
inline void ClearFlags() noexcept
135138
{
136-
flags = 0;
139+
m_flags = 0;
137140
}
138-
inline unsigned char GetFlags() const noexcept { return flags; }
139-
inline bool IsDirty() const noexcept { return flags & DIRTY; }
140-
inline bool IsFresh() const noexcept { return flags & FRESH; }
141+
inline uint8_t GetFlags() const noexcept { return m_flags; }
142+
inline bool IsDirty() const noexcept { return m_flags & DIRTY; }
143+
inline bool IsFresh() const noexcept { return m_flags & FRESH; }
141144
};
142145

143146
/**

src/test/fuzz/coins_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ FUZZ_TARGET(coins_view, .init = initialize_coins_view)
125125
LIMITED_WHILE(good_data && fuzzed_data_provider.ConsumeBool(), 10'000)
126126
{
127127
CCoinsCacheEntry coins_cache_entry;
128-
coins_cache_entry.AddFlags(fuzzed_data_provider.ConsumeIntegral<unsigned char>());
128+
coins_cache_entry.AddFlags(fuzzed_data_provider.ConsumeIntegral<uint8_t>());
129129
if (fuzzed_data_provider.ConsumeBool()) {
130130
coins_cache_entry.coin = random_coin;
131131
} else {

0 commit comments

Comments
 (0)