Skip to content

Commit 205bdd0

Browse files
committed
xhash/asert: remove redundant MaxTarget constant in favor of two256m1
1 parent 66da893 commit 205bdd0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

consensus/xhash/asert_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,17 @@ func TestASERTNextTarget_BCHNVectors(t *testing.T) {
319319
})
320320
}
321321
}
322+
323+
func TestASERTMaxTargetConsistency(t *testing.T) {
324+
d1 := big.NewInt(1)
325+
targetFromDiff := difficultyToTarget(d1)
326+
327+
if targetFromDiff.Cmp(two256m1) != 0 {
328+
t.Fatalf("expected target for difficulty=1 to be two256m1, got %v", targetFromDiff)
329+
}
330+
331+
roundTrip := targetToDifficulty(targetFromDiff)
332+
if roundTrip.Cmp(d1) != 0 {
333+
t.Fatalf("roundtrip diff→target→diff failed: want 1, got %v", roundTrip)
334+
}
335+
}

consensus/xhash/consensus.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ var (
4646
InitialBlockRewardWei = new(big.Int).Mul(big.NewInt(50), big.NewInt(1e18))
4747
// A reserved system address to store maturity schedules in the state trie.
4848
lockboxAddress = common.HexToAddress("0x0000000000000000000000000000000000000042")
49-
50-
MaxTarget = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1))
5149
)
5250

5351
// Various error messages to mark blocks invalid. These should be private to
@@ -329,7 +327,7 @@ func (xhash *XHash) CalcDifficulty(chain consensus.ChainHeaderReader, time uint6
329327
xhash.asertAnchorTarget,
330328
evalHeight,
331329
evalTime,
332-
MaxTarget,
330+
two256m1,
333331
)
334332

335333
return targetToDifficulty(nextTarget)

0 commit comments

Comments
 (0)