summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2020-06-26 17:37:50 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2020-06-26 17:37:50 +0000
commitef04aeca518bde05c4c235542b663a42741a8b25 (patch)
treeceda8b1b08ea91bafd4e956a5ff7755e4f8d7503
parent8e906f14af22aaccc58de9faa0c17d4c7228cccc (diff)
BIP 8: Fix timeout logic
-rw-r--r--bip-0008.mediawiki13
1 files changed, 5 insertions, 8 deletions
diff --git a/bip-0008.mediawiki b/bip-0008.mediawiki
index 612fd42..7251d1d 100644
--- a/bip-0008.mediawiki
+++ b/bip-0008.mediawiki
@@ -118,21 +118,16 @@ We remain in the initial state until we reach the start block height.
}
return DEFINED;
-After a period in the STARTED state, if we're past the timeout, we switch to LOCKED_IN or FAILING. If not, we tally the bits set,
+After a period in the STARTED state, we tally the bits set,
and transition to LOCKED_IN if a sufficient number of blocks in the past period set the deployment bit in their
version numbers. The threshold is ≥1916 blocks (95% of 2016), or ≥1512 for testnet (75% of 2016).
-The transition to FAILING takes precedence, as otherwise an ambiguity can arise.
-There could be two non-overlapping deployments on the same bit, where the first one transitions to LOCKED_IN while the
-other one simultaneously transitions to STARTED, which would mean both would demand setting the bit.
+If the threshold hasn't been met, and we reach the timeout, then we either transition to LOCKED_IN state anyway (if lockinontimeout is true), or we transition to FAILING.
Note that a block's state never depends on its own nVersion; only on that of its ancestors.
case STARTED:
- if (block.height >= timeoutheight) {
- return (lockinontimeout == true) ? LOCKED_IN : FAILING;
-
int count = 0;
- walk = block;
+ walk = block.parent;
for (i = 0; i < 2016; i++) {
walk = walk.parent;
if (walk.nVersion & 0xE0000000 == 0x20000000 && (walk.nVersion >> bit) & 1 == 1) {
@@ -141,6 +136,8 @@ Note that a block's state never depends on its own nVersion; only on that of its
}
if (count >= threshold) {
return LOCKED_IN;
+ } else if (block.height >= timeoutheight) {
+ return (lockinontimeout == true) ? LOCKED_IN : FAILING;
}
return STARTED;