From 7d214047cfe4610d4c9a44d42ff4038ba84349f3 Mon Sep 17 00:00:00 2001 From: Sammy Libre Date: Mon, 5 Dec 2016 21:28:58 +0500 Subject: [PATCH] Add option to bypass share validation --- config.example.json | 3 ++- go-pool/pool/pool.go | 1 + go-pool/stratum/miner.go | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config.example.json b/config.example.json index de50074..c425d3a 100644 --- a/config.example.json +++ b/config.example.json @@ -1,6 +1,7 @@ { "address": "46BeWrHpwXmHDpDEUmZBWZfoQpdc6HaERCNmx1pEYL2rAcuwufPN9rXHHtyUA4QVy66qeFQkn6sfK8aHYjA3jk3o1Bv16em", - "bypassAddressValidation": false, + "bypassAddressValidation": true, + "bypassShareValidation": true, "threads": 2, diff --git a/go-pool/pool/pool.go b/go-pool/pool/pool.go index f76fcae..eb7e011 100644 --- a/go-pool/pool/pool.go +++ b/go-pool/pool/pool.go @@ -3,6 +3,7 @@ package pool type Config struct { Address string `json:"address"` BypassAddressValidation bool `json:"bypassAddressValidation"` + BypassShareValidation bool `json:"bypassShareValidation"` Stratum Stratum `json:"stratum"` Daemon Daemon `json:"daemon"` diff --git a/go-pool/stratum/miner.go b/go-pool/stratum/miner.go index 9a1218a..27984ee 100644 --- a/go-pool/stratum/miner.go +++ b/go-pool/stratum/miner.go @@ -110,10 +110,16 @@ func (m *Miner) processShare(s *StratumServer, job *Job, t *BlockTemplate, nonce nonceBuff, _ := hex.DecodeString(nonce) copy(shareBuff[39:], nonceBuff) - convertedBlob := cnutil.ConvertBlob(shareBuff) - hashBytes := hashing.Hash(convertedBlob, false) + var hashBytes, convertedBlob []byte - if hex.EncodeToString(hashBytes) != result { + if s.config.BypassShareValidation { + hashBytes, _ = hex.DecodeString(result) + } else { + convertedBlob = cnutil.ConvertBlob(shareBuff) + hashBytes = hashing.Hash(convertedBlob, false) + } + + if !s.config.BypassShareValidation && hex.EncodeToString(hashBytes) != result { log.Printf("Bad hash from miner %v@%v", m.Login, m.IP) return false } @@ -125,6 +131,9 @@ func (m *Miner) processShare(s *StratumServer, job *Job, t *BlockTemplate, nonce if err != nil { log.Printf("Block submission failure at height %v: %v", t.Height, err) } else { + if len(convertedBlob) == 0 { + convertedBlob = cnutil.ConvertBlob(shareBuff) + } blockFastHash := hex.EncodeToString(hashing.FastHash(convertedBlob)) // Immediately refresh current BT and send new jobs s.refreshBlockTemplate(true)