From c2d9c33000c2eb2bc08b586e09a385bdb726cde0 Mon Sep 17 00:00:00 2001 From: yuriy0803 <68668177+yuriy0803@users.noreply.github.com> Date: Sun, 7 May 2023 09:58:33 +0200 Subject: [PATCH] support Antminer E9 Pro test test --- util/util.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/util/util.go b/util/util.go index 0431ef8..b261491 100644 --- a/util/util.go +++ b/util/util.go @@ -36,7 +36,17 @@ func MakeTimestamp() int64 { func GetTargetHex(diff int64) string { difficulty := big.NewInt(diff) diff1 := new(big.Int).Div(pow256, difficulty) - return string(hexutil.Encode(diff1.Bytes())) + targetBytes := diff1.Bytes() + + // The target bytes should be exactly 32 bytes long. + if len(targetBytes) < 32 { + padding := make([]byte, 32-len(targetBytes)) + targetBytes = append(padding, targetBytes...) + } + + targetStr := hexutil.Encode(targetBytes) + + return targetStr } func TargetHexToDiff(targetHex string) *big.Int {