mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-15 12:20:17 +01:00
Merge pull request #1985 from guggero/pow-no-retargeting
blockchain+chaincfg: disable retargeting for regtest
This commit is contained in:
commit
7fd5c1e92c
2 changed files with 15 additions and 1 deletions
|
@ -219,7 +219,15 @@ func (b *BlockChain) findPrevTestNetDifficulty(startNode *blockNode) uint32 {
|
||||||
// This function differs from the exported CalcNextRequiredDifficulty in that
|
// This function differs from the exported CalcNextRequiredDifficulty in that
|
||||||
// the exported version uses the current best chain as the previous block node
|
// the exported version uses the current best chain as the previous block node
|
||||||
// while this function accepts any block node.
|
// while this function accepts any block node.
|
||||||
func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode, newBlockTime time.Time) (uint32, error) {
|
func (b *BlockChain) calcNextRequiredDifficulty(lastNode *blockNode,
|
||||||
|
newBlockTime time.Time) (uint32, error) {
|
||||||
|
|
||||||
|
// Emulate the same behavior as Bitcoin Core that for regtest there is
|
||||||
|
// no difficulty retargeting.
|
||||||
|
if b.chainParams.PoWNoRetargeting {
|
||||||
|
return b.chainParams.PowLimitBits, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Genesis block.
|
// Genesis block.
|
||||||
if lastNode == nil {
|
if lastNode == nil {
|
||||||
return b.chainParams.PowLimitBits, nil
|
return b.chainParams.PowLimitBits, nil
|
||||||
|
|
|
@ -183,6 +183,11 @@ type Params struct {
|
||||||
// block in compact form.
|
// block in compact form.
|
||||||
PowLimitBits uint32
|
PowLimitBits uint32
|
||||||
|
|
||||||
|
// PoWNoRetargeting defines whether the network has difficulty
|
||||||
|
// retargeting enabled or not. This should only be set to true for
|
||||||
|
// regtest like networks.
|
||||||
|
PoWNoRetargeting bool
|
||||||
|
|
||||||
// These fields define the block heights at which the specified softfork
|
// These fields define the block heights at which the specified softfork
|
||||||
// BIP became active.
|
// BIP became active.
|
||||||
BIP0034Height int32
|
BIP0034Height int32
|
||||||
|
@ -432,6 +437,7 @@ var RegressionNetParams = Params{
|
||||||
GenesisHash: ®TestGenesisHash,
|
GenesisHash: ®TestGenesisHash,
|
||||||
PowLimit: regressionPowLimit,
|
PowLimit: regressionPowLimit,
|
||||||
PowLimitBits: 0x207fffff,
|
PowLimitBits: 0x207fffff,
|
||||||
|
PoWNoRetargeting: true,
|
||||||
CoinbaseMaturity: 100,
|
CoinbaseMaturity: 100,
|
||||||
BIP0034Height: 100000000, // Not active - Permit ver 1 blocks
|
BIP0034Height: 100000000, // Not active - Permit ver 1 blocks
|
||||||
BIP0065Height: 1351, // Used by regression tests
|
BIP0065Height: 1351, // Used by regression tests
|
||||||
|
|
Loading…
Add table
Reference in a new issue