-
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 10, 2023
1 parent
34c8148
commit 248ddd6
Showing
16 changed files
with
371 additions
and
283 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 |
---|---|---|
|
@@ -9,4 +9,5 @@ type Block interface { | |
GetOrder() uint | ||
HasParents() bool | ||
GetMainParent() uint | ||
GetHeight() uint | ||
} |
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 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.
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
package difficultymanager | ||
|
||
import ( | ||
"math/big" | ||
"time" | ||
|
||
"github.com/Qitmeer/qng/consensus/model" | ||
"github.com/Qitmeer/qng/core/types" | ||
"github.com/Qitmeer/qng/core/types/pow" | ||
"github.com/Qitmeer/qng/params" | ||
) | ||
|
||
// 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 model.Block, newBlockTime time.Time, powInstance pow.IPow) (uint32, error) | ||
CalcEasiestDifficulty(bits uint32, duration time.Duration, powInstance pow.IPow) uint32 | ||
GetCurrentPowDiff(ib model.Block, powType pow.PowType) *big.Int | ||
} | ||
|
||
func NewDiffManager(b model.BlockChain, cfg *params.Params) DifficultyManager { | ||
switch cfg.PowConfig.DifficultyMode { | ||
case types.DIFFICULTY_MODE_KASPAD: | ||
return &kaspadDiff{ | ||
b: b, | ||
powMax: cfg.PowConfig.MeerXKeccakV1PowLimit, | ||
difficultyAdjustmentWindowSize: int(cfg.WorkDiffWindowSize), | ||
disableDifficultyAdjustment: false, | ||
targetTimePerBlock: cfg.TargetTimePerBlock, | ||
genesisBits: cfg.PowConfig.MeerXKeccakV1PowLimitBits, | ||
cfg: cfg, | ||
} | ||
} | ||
return &meerDiff{ | ||
b: b, | ||
cfg: cfg, | ||
} | ||
} |
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.