Skip to content

Commit 5da119e

Browse files
committed
versionbits: Change BIP9Stats to uint32_t types
1 parent a679040 commit 5da119e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/test/fuzz/versionbits.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ FUZZ_TARGET(versionbits, .init = initialize)
117117
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
118118

119119
// making period/max_periods larger slows these tests down significantly
120-
const int period = 32;
120+
const uint32_t period = 32;
121121
const size_t max_periods = 16;
122122
const size_t max_blocks = 2 * period * max_periods;
123123

124-
const int threshold = fuzzed_data_provider.ConsumeIntegralInRange(1, period);
124+
const uint32_t threshold = fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(1, period);
125125
assert(0 < threshold && threshold <= period); // must be able to both pass and fail threshold!
126126

127127
// too many blocks at 10min each might cause uint32_t time to overflow if
@@ -199,7 +199,7 @@ FUZZ_TARGET(versionbits, .init = initialize)
199199
while (fuzzed_data_provider.remaining_bytes() > 0) { // early exit; no need for LIMITED_WHILE
200200
// all blocks in these periods either do or don't signal
201201
bool signal = fuzzed_data_provider.ConsumeBool();
202-
for (int b = 0; b < period; ++b) {
202+
for (uint32_t b = 0; b < period; ++b) {
203203
blocks.mine_block(signal);
204204
}
205205

@@ -211,7 +211,7 @@ FUZZ_TARGET(versionbits, .init = initialize)
211211
// now we mine the final period and check that everything looks sane
212212

213213
// count the number of signalling blocks
214-
int blocks_sig = 0;
214+
uint32_t blocks_sig = 0;
215215

216216
// get the info for the first block of the period
217217
CBlockIndex* prev = blocks.tip();
@@ -230,7 +230,7 @@ FUZZ_TARGET(versionbits, .init = initialize)
230230
assert(exp_since <= prev_next_height);
231231

232232
// mine (period-1) blocks and check state
233-
for (int b = 1; b < period; ++b) {
233+
for (uint32_t b = 1; b < period; ++b) {
234234
const bool signal = (signalling_mask >> (b % 32)) & 1;
235235
if (signal) ++blocks_sig;
236236

src/versionbits.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ typedef std::map<const CBlockIndex*, ThresholdState> ThresholdConditionCache;
4141
/** Display status of an in-progress BIP9 softfork */
4242
struct BIP9Stats {
4343
/** Length of blocks of the BIP9 signalling period */
44-
int period;
44+
uint32_t period;
4545
/** Number of blocks with the version bit set required to activate the softfork */
46-
int threshold;
46+
uint32_t threshold;
4747
/** Number of blocks elapsed since the beginning of the current period */
48-
int elapsed;
48+
uint32_t elapsed;
4949
/** Number of blocks with the version bit set since the beginning of the current period */
50-
int count;
50+
uint32_t count;
5151
/** False if there are not enough blocks left in this period to pass activation threshold */
5252
bool possible;
5353
};

0 commit comments

Comments
 (0)