Skip to content

Commit

Permalink
remove unuse code
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcrypto committed Dec 11, 2023
1 parent a8c673f commit d94a47a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 35 deletions.
25 changes: 0 additions & 25 deletions common/math/maxmin.go

This file was deleted.

5 changes: 0 additions & 5 deletions core/types/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,4 @@ const (
// MaxAmount is the maximum transaction amount allowed in atoms.
// TODO, relocate the coin related item to chain's params
MaxAmount = 21e6 * AtomsPerCoin

// MEER difficulty adjustment
DIFFICULTY_MODE_MEER = 0
// KASPAD difficulty adjustment
DIFFICULTY_MODE_KASPAD
)
7 changes: 7 additions & 0 deletions core/types/pow/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ var (
OneLsh256 = new(big.Int).Lsh(bigOne, 256)
)

const (
// MEER difficulty adjustment
DIFFICULTY_MODE_MEER = 0
// KASPAD difficulty adjustment
DIFFICULTY_MODE_KASPAD
)

// HashToBig converts a hash.Hash into a big.Int that can be used to
// perform math comparisons.
func HashToBig(hash *hash.Hash) *big.Int {
Expand Down
4 changes: 2 additions & 2 deletions core/types/pow/difficultymanager/difficultymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package difficultymanager

import (
"github.com/Qitmeer/qng/consensus/model"
"github.com/Qitmeer/qng/core/types"
"github.com/Qitmeer/qng/core/types/pow"
"github.com/Qitmeer/qng/params"
)

func NewDiffManager(b model.BlockChain, cfg *params.Params) model.DifficultyManager {
switch cfg.PowConfig.DifficultyMode {
case types.DIFFICULTY_MODE_KASPAD:
case pow.DIFFICULTY_MODE_KASPAD:
return &kaspadDiff{
b: b,
powMax: cfg.PowConfig.MeerXKeccakV1PowLimit,
Expand Down
4 changes: 2 additions & 2 deletions core/types/pow/difficultymanager/kaspad.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package difficultymanager

import (
"math"
"math/big"
"time"

"github.com/Qitmeer/qng/common/hash"
"github.com/Qitmeer/qng/common/math"
"github.com/Qitmeer/qng/consensus/model"
"github.com/Qitmeer/qng/core/types"
"github.com/Qitmeer/qng/core/types/pow"
Expand Down Expand Up @@ -159,7 +159,7 @@ func (dm *kaspadDiff) requiredDifficultyFromTargetsWindow(targetsWindow blockWin
newTarget := targetsWindow.AverageTarget()
newTarget.
// We need to clamp the timestamp difference to 1 so that we'll never get a 0 target.
Mul(newTarget, div.SetInt64(math.MaxInt64Val(windowMaxTimeStamp-windowMinTimestamp, 1))).
Mul(newTarget, div.SetInt64(int64(math.Max(float64(windowMaxTimeStamp-windowMinTimestamp), 1)))).
Div(newTarget, div.SetInt64(dm.targetTimePerBlock.Milliseconds())).
Div(newTarget, div.SetUint64(uint64(len(targetsWindow))))
if newTarget.Cmp(dm.powMax) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion params/params_mixnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var MixNetParams = Params{
},
// after this height the big graph will be the main pow graph
AdjustmentStartMainHeight: 1440 * 15 / mixTargetTimePerBlock,
DifficultyMode: types.DIFFICULTY_MODE_KASPAD,
DifficultyMode: pow.DIFFICULTY_MODE_KASPAD,
},

WorkDiffAlpha: 1,
Expand Down

0 comments on commit d94a47a

Please sign in to comment.