1
0
mirror of https://github.com/bitcoin/bips.git synced 2025-05-12 12:03:29 +00:00

Merge pull request #1063 from ajtowns/202102-bip8-simplify-mustsignal-check

bip 8: simplify MUST_SIGNAL check
This commit is contained in:
Luke Dashjr 2021-02-08 18:46:11 +00:00 committed by GitHub
commit ec213e18c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,16 +181,16 @@ Blocks received while in the MUST_SIGNAL phase must be checked to ensure that th
if (GetStateForBlock(block) == MUST_SIGNAL) { if (GetStateForBlock(block) == MUST_SIGNAL) {
int nonsignal = 0; int nonsignal = 0;
int count = 1 + (block.nHeight % 2016);
walk = block; walk = block;
while (count > 0) { while (true) {
--count;
if ((walk.nVersion & 0xE0000000) != 0x20000000 || ((walk.nVersion >> bit) & 1) != 1) { if ((walk.nVersion & 0xE0000000) != 0x20000000 || ((walk.nVersion >> bit) & 1) != 1) {
++nonsignal; ++nonsignal;
if (nonsignal + threshold > 2016) { if (nonsignal > 2016 - threshold) {
return state.Invalid(BlockValidationResult::RECENT_CONSENSUS_CHANGE, "bad-version-bip8-must-signal"); return state.Invalid(BlockValidationResult::RECENT_CONSENSUS_CHANGE, "bad-version-bip8-must-signal");
} }
} else if (nonsignal == 0) { }
if (walk.nHeight % 2016 == 0) {
// checked every block in this retarget period
break; break;
} }
walk = walk.parent; walk = walk.parent;