mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-07-07 05:12:31 +00:00
[NOD-1257] Disable difficulty adjustment on simnet (#862)
* [NOD-1257] Disable difficulty adjustment on simnet * [NOD-1257] Explictly set DisableDifficultyAdjustment everywhere
This commit is contained in:
parent
91f0fe5740
commit
aa9556aa59
@ -15,7 +15,7 @@ import (
|
|||||||
// block given its bluest parent.
|
// block given its bluest parent.
|
||||||
func (dag *BlockDAG) requiredDifficulty(bluestParent *blockNode, newBlockTime mstime.Time) uint32 {
|
func (dag *BlockDAG) requiredDifficulty(bluestParent *blockNode, newBlockTime mstime.Time) uint32 {
|
||||||
// Genesis block.
|
// Genesis block.
|
||||||
if bluestParent == nil || bluestParent.blueScore < dag.difficultyAdjustmentWindowSize+1 {
|
if dag.Params.DisableDifficultyAdjustment || bluestParent == nil || bluestParent.blueScore < dag.difficultyAdjustmentWindowSize+1 {
|
||||||
return dag.powMaxBits
|
return dag.powMaxBits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ func TestCalcWork(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDifficulty(t *testing.T) {
|
func TestDifficulty(t *testing.T) {
|
||||||
params := dagconfig.SimnetParams
|
params := dagconfig.MainnetParams
|
||||||
params.K = 1
|
params.K = 1
|
||||||
params.DifficultyAdjustmentWindowSize = 264
|
params.DifficultyAdjustmentWindowSize = 264
|
||||||
dag, teardownFunc, err := DAGSetup("TestDifficulty", true, Config{
|
dag, teardownFunc, err := DAGSetup("TestDifficulty", true, Config{
|
||||||
|
@ -178,6 +178,9 @@ type Params struct {
|
|||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||||
EnableNonNativeSubnetworks bool
|
EnableNonNativeSubnetworks bool
|
||||||
|
|
||||||
|
// DisableDifficultyAdjustment determine whether to use difficulty
|
||||||
|
DisableDifficultyAdjustment bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NormalizeRPCServerAddress returns addr with the current network default
|
// NormalizeRPCServerAddress returns addr with the current network default
|
||||||
@ -235,6 +238,8 @@ var MainnetParams = Params{
|
|||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||||
EnableNonNativeSubnetworks: false,
|
EnableNonNativeSubnetworks: false,
|
||||||
|
|
||||||
|
DisableDifficultyAdjustment: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegressionNetParams defines the network parameters for the regression test
|
// RegressionNetParams defines the network parameters for the regression test
|
||||||
@ -288,6 +293,8 @@ var RegressionNetParams = Params{
|
|||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||||
EnableNonNativeSubnetworks: false,
|
EnableNonNativeSubnetworks: false,
|
||||||
|
|
||||||
|
DisableDifficultyAdjustment: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestnetParams defines the network parameters for the test Kaspa network.
|
// TestnetParams defines the network parameters for the test Kaspa network.
|
||||||
@ -339,6 +346,8 @@ var TestnetParams = Params{
|
|||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||||
EnableNonNativeSubnetworks: false,
|
EnableNonNativeSubnetworks: false,
|
||||||
|
|
||||||
|
DisableDifficultyAdjustment: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimnetParams defines the network parameters for the simulation test Kaspa
|
// SimnetParams defines the network parameters for the simulation test Kaspa
|
||||||
@ -394,6 +403,8 @@ var SimnetParams = Params{
|
|||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||||
EnableNonNativeSubnetworks: false,
|
EnableNonNativeSubnetworks: false,
|
||||||
|
|
||||||
|
DisableDifficultyAdjustment: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// DevnetParams defines the network parameters for the development Kaspa network.
|
// DevnetParams defines the network parameters for the development Kaspa network.
|
||||||
@ -445,6 +456,8 @@ var DevnetParams = Params{
|
|||||||
|
|
||||||
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
// EnableNonNativeSubnetworks enables non-native/coinbase transactions
|
||||||
EnableNonNativeSubnetworks: false,
|
EnableNonNativeSubnetworks: false,
|
||||||
|
|
||||||
|
DisableDifficultyAdjustment: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user