mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
Simplify chain configuration.
This commit is contained in:
parent
b40a6f86ef
commit
3318a24a88
3 changed files with 49 additions and 57 deletions
|
@ -111,8 +111,7 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, flags BehaviorFlags)
|
||||||
// upgraded. This is part of BIP0034.
|
// upgraded. This is part of BIP0034.
|
||||||
if blockHeader.Version < 2 {
|
if blockHeader.Version < 2 {
|
||||||
if b.isMajorityVersion(2, prevNode,
|
if b.isMajorityVersion(2, prevNode,
|
||||||
b.chainParams.BlockV1RejectNumRequired,
|
b.chainParams.BlockRejectNumRequired) {
|
||||||
b.chainParams.BlockV1RejectNumToCheck) {
|
|
||||||
|
|
||||||
str := "new blocks with version %d are no " +
|
str := "new blocks with version %d are no " +
|
||||||
"longer valid"
|
"longer valid"
|
||||||
|
@ -128,8 +127,7 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, flags BehaviorFlags)
|
||||||
if blockHeader.Version >= serializedHeightVersion {
|
if blockHeader.Version >= serializedHeightVersion {
|
||||||
if b.isMajorityVersion(serializedHeightVersion,
|
if b.isMajorityVersion(serializedHeightVersion,
|
||||||
prevNode,
|
prevNode,
|
||||||
b.chainParams.CoinbaseBlockHeightNumRequired,
|
b.chainParams.BlockEnforceNumRequired) {
|
||||||
b.chainParams.CoinbaseBlockHeightNumToCheck) {
|
|
||||||
|
|
||||||
expectedHeight := int64(0)
|
expectedHeight := int64(0)
|
||||||
if prevNode != nil {
|
if prevNode != nil {
|
||||||
|
|
|
@ -610,10 +610,13 @@ func (b *BlockChain) pruneBlockNodes() error {
|
||||||
|
|
||||||
// isMajorityVersion determines if a previous number of blocks in the chain
|
// isMajorityVersion determines if a previous number of blocks in the chain
|
||||||
// starting with startNode are at least the minimum passed version.
|
// starting with startNode are at least the minimum passed version.
|
||||||
func (b *BlockChain) isMajorityVersion(minVer int32, startNode *blockNode, numRequired, numToCheck uint64) bool {
|
func (b *BlockChain) isMajorityVersion(minVer int32, startNode *blockNode,
|
||||||
|
numRequired uint64) bool {
|
||||||
|
|
||||||
numFound := uint64(0)
|
numFound := uint64(0)
|
||||||
iterNode := startNode
|
iterNode := startNode
|
||||||
for i := uint64(0); i < numToCheck && iterNode != nil; i++ {
|
for i := uint64(0); i < b.chainParams.BlockUpgradeNumToCheck &&
|
||||||
|
numFound < numRequired && iterNode != nil; i++ {
|
||||||
// This node has a version that is at least the minimum version.
|
// This node has a version that is at least the minimum version.
|
||||||
if iterNode.version >= minVer {
|
if iterNode.version >= minVer {
|
||||||
numFound++
|
numFound++
|
||||||
|
|
|
@ -67,15 +67,16 @@ type Params struct {
|
||||||
// Checkpoints ordered from oldest to newest.
|
// Checkpoints ordered from oldest to newest.
|
||||||
Checkpoints []Checkpoint
|
Checkpoints []Checkpoint
|
||||||
|
|
||||||
// Reject version 1 blocks once a majority of the network has upgraded.
|
// Enforce current block version once network has
|
||||||
// This is part of BIP0034.
|
// upgraded. This is part of BIP0034.
|
||||||
BlockV1RejectNumRequired uint64
|
BlockEnforceNumRequired uint64
|
||||||
BlockV1RejectNumToCheck uint64
|
|
||||||
|
|
||||||
// Ensure coinbase starts with serialized block heights for version 2
|
// Reject previous block versions once network has
|
||||||
// blocks or newer once a majority of the network has upgraded.
|
// upgraded. This is part of BIP0034.
|
||||||
CoinbaseBlockHeightNumRequired uint64
|
BlockRejectNumRequired uint64
|
||||||
CoinbaseBlockHeightNumToCheck uint64
|
|
||||||
|
// The number of nodes to check. This is part of BIP0034.
|
||||||
|
BlockUpgradeNumToCheck uint64
|
||||||
|
|
||||||
// Mempool parameters
|
// Mempool parameters
|
||||||
RelayNonStdTxs bool
|
RelayNonStdTxs bool
|
||||||
|
@ -127,18 +128,15 @@ var MainNetParams = Params{
|
||||||
{319400, newShaHashFromStr("000000000000000021c6052e9becade189495d1c539aa37c58917305fd15f13b")},
|
{319400, newShaHashFromStr("000000000000000021c6052e9becade189495d1c539aa37c58917305fd15f13b")},
|
||||||
},
|
},
|
||||||
|
|
||||||
// Reject version 1 blocks once a majority of the network has upgraded.
|
// Enforce current block version once majority of the network has
|
||||||
// 95% (950 / 1000)
|
// upgraded.
|
||||||
// This is part of BIP0034.
|
|
||||||
BlockV1RejectNumRequired: 950,
|
|
||||||
BlockV1RejectNumToCheck: 1000,
|
|
||||||
|
|
||||||
// Ensure coinbase starts with serialized block heights for version 2
|
|
||||||
// blocks or newer once a majority of the network has upgraded.
|
|
||||||
// 75% (750 / 1000)
|
// 75% (750 / 1000)
|
||||||
// This is part of BIP0034.
|
// Reject previous block versions once a majority of the network has
|
||||||
CoinbaseBlockHeightNumRequired: 750,
|
// upgraded.
|
||||||
CoinbaseBlockHeightNumToCheck: 1000,
|
// 95% (950 / 1000)
|
||||||
|
BlockEnforceNumRequired: 750,
|
||||||
|
BlockRejectNumRequired: 950,
|
||||||
|
BlockUpgradeNumToCheck: 1000,
|
||||||
|
|
||||||
// Mempool parameters
|
// Mempool parameters
|
||||||
RelayNonStdTxs: false,
|
RelayNonStdTxs: false,
|
||||||
|
@ -176,18 +174,15 @@ var RegressionNetParams = Params{
|
||||||
// Checkpoints ordered from oldest to newest.
|
// Checkpoints ordered from oldest to newest.
|
||||||
Checkpoints: nil,
|
Checkpoints: nil,
|
||||||
|
|
||||||
// Reject version 1 blocks once a majority of the network has upgraded.
|
// Enforce current block version once majority of the network has
|
||||||
// 75% (75 / 100)
|
// upgraded.
|
||||||
// This is part of BIP0034.
|
// 75% (750 / 1000)
|
||||||
BlockV1RejectNumRequired: 75,
|
// Reject previous block versions once a majority of the network has
|
||||||
BlockV1RejectNumToCheck: 100,
|
// upgraded.
|
||||||
|
// 95% (950 / 1000)
|
||||||
// Ensure coinbase starts with serialized block heights for version 2
|
BlockEnforceNumRequired: 750,
|
||||||
// blocks or newer once a majority of the network has upgraded.
|
BlockRejectNumRequired: 950,
|
||||||
// 51% (51 / 100)
|
BlockUpgradeNumToCheck: 1000,
|
||||||
// This is part of BIP0034.
|
|
||||||
CoinbaseBlockHeightNumRequired: 51,
|
|
||||||
CoinbaseBlockHeightNumToCheck: 100,
|
|
||||||
|
|
||||||
// Mempool parameters
|
// Mempool parameters
|
||||||
RelayNonStdTxs: true,
|
RelayNonStdTxs: true,
|
||||||
|
@ -227,18 +222,15 @@ var TestNet3Params = Params{
|
||||||
{546, newShaHashFromStr("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")},
|
{546, newShaHashFromStr("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")},
|
||||||
},
|
},
|
||||||
|
|
||||||
// Reject version 1 blocks once a majority of the network has upgraded.
|
// Enforce current block version once majority of the network has
|
||||||
// 75% (75 / 100)
|
// upgraded.
|
||||||
// This is part of BIP0034.
|
|
||||||
BlockV1RejectNumRequired: 75,
|
|
||||||
BlockV1RejectNumToCheck: 100,
|
|
||||||
|
|
||||||
// Ensure coinbase starts with serialized block heights for version 2
|
|
||||||
// blocks or newer once a majority of the network has upgraded.
|
|
||||||
// 51% (51 / 100)
|
// 51% (51 / 100)
|
||||||
// This is part of BIP0034.
|
// Reject previous block versions once a majority of the network has
|
||||||
CoinbaseBlockHeightNumRequired: 51,
|
// upgraded.
|
||||||
CoinbaseBlockHeightNumToCheck: 100,
|
// 75% (75 / 100)
|
||||||
|
BlockEnforceNumRequired: 51,
|
||||||
|
BlockRejectNumRequired: 75,
|
||||||
|
BlockUpgradeNumToCheck: 100,
|
||||||
|
|
||||||
// Mempool parameters
|
// Mempool parameters
|
||||||
RelayNonStdTxs: true,
|
RelayNonStdTxs: true,
|
||||||
|
@ -280,16 +272,15 @@ var SimNetParams = Params{
|
||||||
// Checkpoints ordered from oldest to newest.
|
// Checkpoints ordered from oldest to newest.
|
||||||
Checkpoints: nil,
|
Checkpoints: nil,
|
||||||
|
|
||||||
// Reject version 1 blocks once a majority of the network has upgraded.
|
// Enforce current block version once majority of the network has
|
||||||
// 75% (75 / 100)
|
// upgraded.
|
||||||
BlockV1RejectNumRequired: 75,
|
|
||||||
BlockV1RejectNumToCheck: 100,
|
|
||||||
|
|
||||||
// Ensure coinbase starts with serialized block heights for version 2
|
|
||||||
// blocks or newer once a majority of the network has upgraded.
|
|
||||||
// 51% (51 / 100)
|
// 51% (51 / 100)
|
||||||
CoinbaseBlockHeightNumRequired: 51,
|
// Reject previous block versions once a majority of the network has
|
||||||
CoinbaseBlockHeightNumToCheck: 100,
|
// upgraded.
|
||||||
|
// 75% (75 / 100)
|
||||||
|
BlockEnforceNumRequired: 51,
|
||||||
|
BlockRejectNumRequired: 75,
|
||||||
|
BlockUpgradeNumToCheck: 100,
|
||||||
|
|
||||||
// Mempool parameters
|
// Mempool parameters
|
||||||
RelayNonStdTxs: true,
|
RelayNonStdTxs: true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue