Skip to content

Commit ec213e1

Browse files
authored
Merge pull request bitcoin#1063 from ajtowns/202102-bip8-simplify-mustsignal-check
bip 8: simplify MUST_SIGNAL check
2 parents 518fd3f + 63d2800 commit ec213e1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bip-0008.mediawiki

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,16 @@ Blocks received while in the MUST_SIGNAL phase must be checked to ensure that th
181181

182182
if (GetStateForBlock(block) == MUST_SIGNAL) {
183183
int nonsignal = 0;
184-
int count = 1 + (block.nHeight % 2016);
185184
walk = block;
186-
while (count > 0) {
187-
--count;
185+
while (true) {
188186
if ((walk.nVersion & 0xE0000000) != 0x20000000 || ((walk.nVersion >> bit) & 1) != 1) {
189187
++nonsignal;
190-
if (nonsignal + threshold > 2016) {
188+
if (nonsignal > 2016 - threshold) {
191189
return state.Invalid(BlockValidationResult::RECENT_CONSENSUS_CHANGE, "bad-version-bip8-must-signal");
192190
}
193-
} else if (nonsignal == 0) {
191+
}
192+
if (walk.nHeight % 2016 == 0) {
193+
// checked every block in this retarget period
194194
break;
195195
}
196196
walk = walk.parent;

0 commit comments

Comments
 (0)