Browse Source

Asic Antminer E9

port diff 8
You need to
1024*1024*1024*8 = 8589934592
master
yuriy0803 3 years ago
parent
commit
0489c1a5f4
  1. 2
      api.json
  2. 5
      proxy/stratum.go
  3. 18
      util/util.go

2
api.json

@ -15,7 +15,7 @@
"behindReverseProxy": false,
"blockRefreshInterval": "120ms",
"stateUpdateInterval": "3s",
"difficulty": 2000000000,
"difficulty": 8589934592,
"hashrateExpiration": "3h",
"healthCheck": true,

5
proxy/stratum.go

@ -198,11 +198,6 @@ func (cs *Session) handleTCPMessage(s *ProxyServer, req *StratumReq) error {
return err
}
if params[1] != "EthereumStratum/1.0.0" {
log.Println("Unsupported stratum version from", cs.ip)
return cs.sendStratumError(req.Id, "unsupported stratum version")
}
cs.ExtranonceSub = true
cs.setStratumMode("EthereumStratum/1.0.0")
log.Println("Nicehash subscribe", cs.ip)

18
util/util.go

@ -1,6 +1,7 @@
package util
import (
"encoding/hex"
"math/big"
"regexp"
"strconv"
@ -18,6 +19,14 @@ var pow256 = math.BigPow(2, 256)
var addressPattern = regexp.MustCompile("^0x[0-9a-fA-F]{40}$")
var zeroHash = regexp.MustCompile("^0?x?0+$")
var Diff1 = StringToBig("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF")
func StringToBig(h string) *big.Int {
n := new(big.Int)
n.SetString(h, 0)
return n
}
func IsValidHexAddress(s string) bool {
if IsZeroHash(s) || !addressPattern.MatchString(s) {
return false
@ -35,8 +44,13 @@ 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()))
diff1 := new(big.Int).Div(Diff1, difficulty)
targetBytes := diff1.Bytes()
if len(targetBytes) < 32 {
padding := make([]byte, 32-len(targetBytes))
targetBytes = append(padding, targetBytes...)
}
return "0x" + hex.EncodeToString(targetBytes)
}
func TargetHexToDiff(targetHex string) *big.Int {

Loading…
Cancel
Save