From 059aa2ef4f6a46b9877bab62837d45f7dcebb4b1 Mon Sep 17 00:00:00 2001 From: Brannon King Date: Thu, 29 Jul 2021 17:21:51 -0400 Subject: [PATCH] [lbry] blockchain: support force active fork deployment --- blockchain/thresholdstate.go | 6 ++++++ blockchain/versionbits.go | 6 ++++++ rpcserver.go | 1 + 3 files changed, 13 insertions(+) diff --git a/blockchain/thresholdstate.go b/blockchain/thresholdstate.go index 5da74a95..8a79f968 100644 --- a/blockchain/thresholdstate.go +++ b/blockchain/thresholdstate.go @@ -302,6 +302,12 @@ func (b *BlockChain) deploymentState(prevNode *blockNode, deploymentID uint32) ( } deployment := &b.chainParams.Deployments[deploymentID] + + // added to mimic LBRYcrd: + if deployment.ForceActiveAt > 0 && prevNode != nil && prevNode.height+1 >= deployment.ForceActiveAt { + return ThresholdActive, nil + } + checker := deploymentChecker{deployment: deployment, chain: b} cache := &b.deploymentCaches[deploymentID] diff --git a/blockchain/versionbits.go b/blockchain/versionbits.go index 28fcde7b..acdbf144 100644 --- a/blockchain/versionbits.go +++ b/blockchain/versionbits.go @@ -195,6 +195,12 @@ func (b *BlockChain) calcNextBlockVersion(prevNode *blockNode) (int32, error) { expectedVersion := uint32(vbTopBits) for id := 0; id < len(b.chainParams.Deployments); id++ { deployment := &b.chainParams.Deployments[id] + + // added to mimic LBRYcrd: + if deployment.ForceActiveAt > 0 && prevNode != nil && prevNode.height+1 >= deployment.ForceActiveAt { + continue + } + cache := &b.deploymentCaches[id] checker := deploymentChecker{deployment: deployment, chain: b} state, err := b.thresholdState(prevNode, checker, cache) diff --git a/rpcserver.go b/rpcserver.go index d1840729..4502a4cd 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -1294,6 +1294,7 @@ func handleGetBlockChainInfo(s *rpcServer, cmd interface{}, closeChan <-chan str Bit: deploymentDetails.BitNumber, StartTime2: int64(deploymentDetails.StartTime), Timeout: int64(deploymentDetails.ExpireTime), + Since: deploymentDetails.ForceActiveAt, } }