mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-12 18:44:59 +01:00
versionbits: Change BIP9Stats to uint32_t types
This commit is contained in:
parent
a679040ec1
commit
5da119e5d0
2 changed files with 9 additions and 9 deletions
|
@ -117,11 +117,11 @@ FUZZ_TARGET(versionbits, .init = initialize)
|
|||
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
||||
|
||||
// making period/max_periods larger slows these tests down significantly
|
||||
const int period = 32;
|
||||
const uint32_t period = 32;
|
||||
const size_t max_periods = 16;
|
||||
const size_t max_blocks = 2 * period * max_periods;
|
||||
|
||||
const int threshold = fuzzed_data_provider.ConsumeIntegralInRange(1, period);
|
||||
const uint32_t threshold = fuzzed_data_provider.ConsumeIntegralInRange<uint32_t>(1, period);
|
||||
assert(0 < threshold && threshold <= period); // must be able to both pass and fail threshold!
|
||||
|
||||
// too many blocks at 10min each might cause uint32_t time to overflow if
|
||||
|
@ -199,7 +199,7 @@ FUZZ_TARGET(versionbits, .init = initialize)
|
|||
while (fuzzed_data_provider.remaining_bytes() > 0) { // early exit; no need for LIMITED_WHILE
|
||||
// all blocks in these periods either do or don't signal
|
||||
bool signal = fuzzed_data_provider.ConsumeBool();
|
||||
for (int b = 0; b < period; ++b) {
|
||||
for (uint32_t b = 0; b < period; ++b) {
|
||||
blocks.mine_block(signal);
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ FUZZ_TARGET(versionbits, .init = initialize)
|
|||
// now we mine the final period and check that everything looks sane
|
||||
|
||||
// count the number of signalling blocks
|
||||
int blocks_sig = 0;
|
||||
uint32_t blocks_sig = 0;
|
||||
|
||||
// get the info for the first block of the period
|
||||
CBlockIndex* prev = blocks.tip();
|
||||
|
@ -230,7 +230,7 @@ FUZZ_TARGET(versionbits, .init = initialize)
|
|||
assert(exp_since <= prev_next_height);
|
||||
|
||||
// mine (period-1) blocks and check state
|
||||
for (int b = 1; b < period; ++b) {
|
||||
for (uint32_t b = 1; b < period; ++b) {
|
||||
const bool signal = (signalling_mask >> (b % 32)) & 1;
|
||||
if (signal) ++blocks_sig;
|
||||
|
||||
|
|
|
@ -41,13 +41,13 @@ typedef std::map<const CBlockIndex*, ThresholdState> ThresholdConditionCache;
|
|||
/** Display status of an in-progress BIP9 softfork */
|
||||
struct BIP9Stats {
|
||||
/** Length of blocks of the BIP9 signalling period */
|
||||
int period;
|
||||
uint32_t period;
|
||||
/** Number of blocks with the version bit set required to activate the softfork */
|
||||
int threshold;
|
||||
uint32_t threshold;
|
||||
/** Number of blocks elapsed since the beginning of the current period */
|
||||
int elapsed;
|
||||
uint32_t elapsed;
|
||||
/** Number of blocks with the version bit set since the beginning of the current period */
|
||||
int count;
|
||||
uint32_t count;
|
||||
/** False if there are not enough blocks left in this period to pass activation threshold */
|
||||
bool possible;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue