Skip to content

Commit

Permalink
restruct
Browse files Browse the repository at this point in the history
  • Loading branch information
wifiboy16 committed Nov 30, 2023
1 parent aedc031 commit 19e6128
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 67 deletions.
2 changes: 1 addition & 1 deletion common/util/math/min.go → common/math/maxmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func MinInt(x, y int) int {
}

// MaxInt64 returns the bigger of x or y.
func MaxInt64(x, y int64) int64 {
func MaxInt64Val(x, y int64) int64 {
if x > y {
return x
}
Expand Down
64 changes: 0 additions & 64 deletions common/util/math/min_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions core/types/pow/difficultymanager/difficultymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"math/big"
"time"

"github.com/Qitmeer/qng/common/util/math"
"github.com/Qitmeer/qng/common/math"
"github.com/Qitmeer/qng/core/types/pow"
"github.com/Qitmeer/qng/params"
)
Expand Down Expand Up @@ -66,7 +66,7 @@ func (dm *difficultyManager) requiredDifficultyFromTargetsWindow(targetsWindow B
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.MaxInt64(windowMaxTimeStamp-windowMinTimestamp, 1))).
Mul(newTarget, div.SetInt64(math.MaxInt64Val(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

0 comments on commit 19e6128

Please sign in to comment.