From 061234ceacea589b545b891ee8879d77387a6abe Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 11 Oct 2023 15:45:10 -0500 Subject: [PATCH] multi: Remove no longer relevant blake256 pad code. This removes the blake256 padding code since it no longer applies. --- pool/client.go | 5 ----- pool/client_test.go | 2 -- pool/endpoint.go | 4 ---- pool/endpoint_test.go | 2 -- pool/hub.go | 14 -------------- 5 files changed, 27 deletions(-) diff --git a/pool/client.go b/pool/client.go index 5e9fb049..c54443a5 100644 --- a/pool/client.go +++ b/pool/client.go @@ -76,9 +76,6 @@ type ClientConfig struct { db Database // SoloPool represents the solo pool mining mode. SoloPool bool - // Blake256Pad represents the extra padding needed for work - // submissions over the getwork RPC. - Blake256Pad []byte // NonceIterations returns the possible header nonce iterations. NonceIterations float64 // FetchMinerDifficulty returns the difficulty information for the @@ -588,8 +585,6 @@ func (c *Client) handleSubmitWorkRequest(ctx context.Context, req *Request, allo } submissionB := make([]byte, getworkDataLen) copy(submissionB[:wire.MaxBlockHeaderPayload], headerB) - copy(submissionB[wire.MaxBlockHeaderPayload:], - c.cfg.Blake256Pad) submission := hex.EncodeToString(submissionB) accepted, err := c.cfg.SubmitWork(ctx, submission) if err != nil { diff --git a/pool/client_test.go b/pool/client_test.go index aa760d9b..b9d85f92 100644 --- a/pool/client_test.go +++ b/pool/client_test.go @@ -31,7 +31,6 @@ var ( powLimit = chaincfg.SimNetParams().PowLimit iterations = math.Pow(2, float64(256-powLimit.BitLen())) - blake256Pad = generateBlake256Pad() maxGenTime = time.Millisecond * 500 cTimeout = time.Millisecond * 2000 hashCalcMax = time.Millisecond * 1500 @@ -39,7 +38,6 @@ var ( new(big.Rat).SetInt(powLimit), maxGenTime) config = &ClientConfig{ ActiveNet: chaincfg.SimNetParams(), - Blake256Pad: blake256Pad, NonceIterations: iterations, MaxGenTime: maxGenTime, FetchMinerDifficulty: func(miner string) (*DifficultyInfo, error) { diff --git a/pool/endpoint.go b/pool/endpoint.go index 17090c40..9a3d9cb4 100644 --- a/pool/endpoint.go +++ b/pool/endpoint.go @@ -26,9 +26,6 @@ type EndpointConfig struct { db Database // SoloPool represents the solo pool mining mode. SoloPool bool - // Blake256Pad represents the extra padding needed for work - // submissions over the getwork RPC. - Blake256Pad []byte // NonceIterations returns the possible header nonce iterations. NonceIterations float64 // MaxConnectionsPerHost represents the maximum number of connections @@ -173,7 +170,6 @@ func (e *Endpoint) connect(ctx context.Context) { ActiveNet: e.cfg.ActiveNet, db: e.cfg.db, SoloPool: e.cfg.SoloPool, - Blake256Pad: e.cfg.Blake256Pad, NonceIterations: e.cfg.NonceIterations, FetchMinerDifficulty: e.cfg.FetchMinerDifficulty, SubmitWork: e.cfg.SubmitWork, diff --git a/pool/endpoint_test.go b/pool/endpoint_test.go index 76f8783b..0b9dd409 100644 --- a/pool/endpoint_test.go +++ b/pool/endpoint_test.go @@ -32,7 +32,6 @@ func testEndpoint(t *testing.T) { powLimit := chaincfg.SimNetParams().PowLimit iterations := math.Pow(2, float64(256-powLimit.BitLen())) maxGenTime := time.Second * 20 - blake256Pad := generateBlake256Pad() poolDiffs := NewDifficultySet(chaincfg.SimNetParams(), new(big.Rat).SetInt(powLimit), maxGenTime) connections := make(map[string]uint32) @@ -42,7 +41,6 @@ func testEndpoint(t *testing.T) { ActiveNet: chaincfg.SimNetParams(), db: db, SoloPool: true, - Blake256Pad: blake256Pad, NonceIterations: iterations, MaxConnectionsPerHost: maxConnsPerHost, FetchMinerDifficulty: func(miner string) (*DifficultyInfo, error) { diff --git a/pool/hub.go b/pool/hub.go index ff40d9d5..f536e0a4 100644 --- a/pool/hub.go +++ b/pool/hub.go @@ -198,7 +198,6 @@ type Hub struct { connections map[string]uint32 connectionsMtx sync.RWMutex endpoint *Endpoint - blake256Pad []byte cacheCh chan CacheUpdateEvent } @@ -216,17 +215,6 @@ func (h *Hub) FetchCacheChannel() chan CacheUpdateEvent { return h.cacheCh } -// generateBlake256Pad creates the extra padding needed for work -// submissions over the getwork RPC. -func generateBlake256Pad() []byte { - blake256Pad := make([]byte, getworkDataLen-wire.MaxBlockHeaderPayload) - blake256Pad[0] = 0x80 - blake256Pad[len(blake256Pad)-9] |= 0x01 - binary.BigEndian.PutUint64(blake256Pad[len(blake256Pad)-8:], - wire.MaxBlockHeaderPayload*8) - return blake256Pad -} - // NewHub initializes the mining pool hub. func NewHub(hcfg *HubConfig) (*Hub, error) { h := &Hub{ @@ -235,7 +223,6 @@ func NewHub(hcfg *HubConfig) (*Hub, error) { connections: make(map[string]uint32), cacheCh: make(chan CacheUpdateEvent, bufferSize), } - h.blake256Pad = generateBlake256Pad() powLimit := new(big.Rat).SetInt(h.cfg.ActiveNet.PowLimit) maxGenTime := h.cfg.MaxGenTime if h.cfg.SoloPool { @@ -317,7 +304,6 @@ func NewHub(hcfg *HubConfig) (*Hub, error) { ActiveNet: h.cfg.ActiveNet, db: h.cfg.DB, SoloPool: h.cfg.SoloPool, - Blake256Pad: h.blake256Pad, NonceIterations: h.cfg.NonceIterations, MaxConnectionsPerHost: h.cfg.MaxConnectionsPerHost, FetchMinerDifficulty: h.poolDiffs.fetchMinerDifficulty,