Skip to content

Commit d97db31

Browse files
committed
ETH: Fix inaccurate default difficulty
1 parent c679c2d commit d97db31

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

DownSessionETH.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ func (down *DownSessionETH) submitResponse(e EventSubmitResponse) {
517517

518518
func (down *DownSessionETH) setDifficulty(e EventSetDifficulty) {
519519
if down.protocol == ProtocolEthereumStratum && down.jobDiff != e.Difficulty {
520-
diff := float64(e.Difficulty) / float64(0xffffffff)
520+
diff := float64(e.Difficulty) / 4294967296.0
521521

522522
var request JSONRPCRequest
523523
request.Method = "mining.set_difficulty"

UpSessionETH.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11-
"math"
1211
"net"
1312
"strconv"
1413
"time"
@@ -349,7 +348,10 @@ func (up *UpSessionETH) handleSetDifficulty(rpcData *JSONRPCLineETH, jsonBytes [
349348
return
350349
}
351350
// nicehash_diff = btcpool_diff / pow(2, 32)
352-
up.defaultDiff = uint64(math.Round(diff * 0xffffffff))
351+
up.defaultDiff = uint64(diff * 4294967296.0)
352+
if glog.V(5) {
353+
glog.Info(up.id, "mining.set_difficulty: ", diff, " -> ", up.defaultDiff)
354+
}
353355

354356
e := EventSetDifficulty{up.defaultDiff}
355357
for _, down := range up.downSessions {

0 commit comments

Comments
 (0)