-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
frankcrypto
committed
Dec 7, 2023
1 parent
35dcd4a
commit 49b08dc
Showing
9 changed files
with
331 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package model | ||
|
||
import ( | ||
"github.com/Qitmeer/qng/common/hash" | ||
"github.com/Qitmeer/qng/rpc/api" | ||
) | ||
|
||
type MeerDag interface { | ||
RegisterAPIs(apis []api.API) | ||
GetBlockIDByTxHash(txhash *hash.Hash) uint64 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
core/types/pow/difficultymanager/interface_difficultymanager.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package difficultymanager | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/Qitmeer/qng/consensus/model" | ||
"github.com/Qitmeer/qng/core/types/pow" | ||
"github.com/Qitmeer/qng/meerdag" | ||
) | ||
|
||
const ( | ||
// MEER difficulty adjustment | ||
DIFFICULTY_MODE_MEER = iota | ||
// KASPAD difficulty adjustment | ||
DIFFICULTY_MODE_KASPAD | ||
) | ||
|
||
// DifficultyManager provides a method to resolve the | ||
// difficulty value of a block | ||
type DifficultyManager interface { | ||
CalcNextRequiredDifficulty(timestamp time.Time, powType pow.PowType) (uint32, error) | ||
RequiredDifficulty(block meerdag.IBlock, newBlockTime time.Time, powInstance pow.IPow) (uint32, error) | ||
} | ||
|
||
func NewDiffManager(b model.BlockChain) DifficultyManager { | ||
switch b.ChainParams().PowConfig.DifficultyMode { | ||
case DIFFICULTY_MODE_KASPAD: | ||
return &kaspadDiff{ | ||
b: b, | ||
powMax: b.ChainParams().PowConfig.MeerXKeccakV1PowLimit, | ||
difficultyAdjustmentWindowSize: int(b.ChainParams().WorkDiffWindowSize), | ||
disableDifficultyAdjustment: false, | ||
targetTimePerBlock: b.ChainParams().TargetTimePerBlock, | ||
genesisBits: b.ChainParams().PowConfig.MeerXKeccakV1PowLimitBits, | ||
} | ||
} | ||
return &meerDiff{ | ||
b: b, | ||
} | ||
} |
60 changes: 0 additions & 60 deletions
60
core/types/pow/difficultymanager/interface_processes_difficultymanager.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.