mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Merge branch 'release/3.0' of github.com:ubiq/go-ubiq into release/3.0
This commit is contained in:
commit
a85aa53456
2 changed files with 9 additions and 11 deletions
|
|
@ -388,14 +388,12 @@ func CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Head
|
||||||
if parentNumber.Cmp(ubqhashConfig.DigishieldModBlock) < 0 {
|
if parentNumber.Cmp(ubqhashConfig.DigishieldModBlock) < 0 {
|
||||||
// Original DigishieldV3
|
// Original DigishieldV3
|
||||||
return calcDifficultyDigishieldV3(chain, parentNumber, parentDiff, parent, digishieldV3Config)
|
return calcDifficultyDigishieldV3(chain, parentNumber, parentDiff, parent, digishieldV3Config)
|
||||||
} else {
|
|
||||||
// Modified DigishieldV3
|
|
||||||
return calcDifficultyDigishieldV3(chain, parentNumber, parentDiff, parent, digishieldV3ModConfig)
|
|
||||||
}
|
}
|
||||||
} else {
|
// Modified DigishieldV3
|
||||||
// Flux
|
return calcDifficultyDigishieldV3(chain, parentNumber, parentDiff, parent, digishieldV3ModConfig)
|
||||||
return calcDifficultyFlux(chain, big.NewInt(int64(time)), big.NewInt(int64(parentTime)), parentNumber, parentDiff, parent)
|
|
||||||
}
|
}
|
||||||
|
// Flux
|
||||||
|
return calcDifficultyFlux(chain, big.NewInt(int64(time)), big.NewInt(int64(parentTime)), parentNumber, parentDiff, parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some weird constants to avoid constant memory allocs for them.
|
// Some weird constants to avoid constant memory allocs for them.
|
||||||
|
|
@ -404,7 +402,7 @@ var (
|
||||||
big10 = big.NewInt(10)
|
big10 = big.NewInt(10)
|
||||||
)
|
)
|
||||||
|
|
||||||
// calcDifficultyLegacy is the difficulty adjustment algorithm. It returns
|
// CalcDifficultyLegacy is the difficulty adjustment algorithm. It returns
|
||||||
// the difficulty that a new block should have when created at time given the
|
// the difficulty that a new block should have when created at time given the
|
||||||
// parent block's time and difficulty. The calculation uses the Legacy rules.
|
// parent block's time and difficulty. The calculation uses the Legacy rules.
|
||||||
func CalcDifficultyLegacy(time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
|
func CalcDifficultyLegacy(time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
|
||||||
|
|
@ -437,10 +435,10 @@ func CalcDifficultyLegacy(time, parentTime uint64, parentNumber, parentDiff *big
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcDifficulty is the difficulty adjustment algorithm. It returns
|
// calcDifficultyDigishieldV3 is the original difficulty adjustment algorithm.
|
||||||
// the difficulty that a new block should have when created at time
|
// It returns the difficulty that a new block should have when created at time
|
||||||
// given the parent block's time and difficulty.
|
// given the parent block's time and difficulty.
|
||||||
// Rewritten to be based on Digibyte's Digishield v3 retargeting
|
// Based on Digibyte's Digishield v3 retargeting
|
||||||
func calcDifficultyDigishieldV3(chain consensus.ChainReader, parentNumber, parentDiff *big.Int, parent *types.Header, digishield *diffConfig) *big.Int {
|
func calcDifficultyDigishieldV3(chain consensus.ChainReader, parentNumber, parentDiff *big.Int, parent *types.Header, digishield *diffConfig) *big.Int {
|
||||||
// holds intermediate values to make the algo easier to read & audit
|
// holds intermediate values to make the algo easier to read & audit
|
||||||
x := new(big.Int)
|
x := new(big.Int)
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ func TestHashRate(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
api := &API{ubqhash}
|
api := &API{ubqhash}
|
||||||
for i := 0; i < len(hashrate); i += 1 {
|
for i := 0; i < len(hashrate); i++ {
|
||||||
if res := api.SubmitHashRate(hashrate[i], ids[i]); !res {
|
if res := api.SubmitHashRate(hashrate[i], ids[i]); !res {
|
||||||
t.Error("remote miner submit hashrate failed")
|
t.Error("remote miner submit hashrate failed")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue