Skip to content

Commit

Permalink
multi: Remove no longer relevant blake256 pad code.
Browse files Browse the repository at this point in the history
This removes the blake256 padding code since it no longer applies.
  • Loading branch information
davecgh committed Oct 11, 2023
1 parent 217ceac commit 061234c
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 27 deletions.
5 changes: 0 additions & 5 deletions pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ 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
poolDiffs = NewDifficultySet(chaincfg.SimNetParams(),
new(big.Rat).SetInt(powLimit), maxGenTime)
config = &ClientConfig{
ActiveNet: chaincfg.SimNetParams(),
Blake256Pad: blake256Pad,
NonceIterations: iterations,
MaxGenTime: maxGenTime,
FetchMinerDifficulty: func(miner string) (*DifficultyInfo, error) {
Expand Down
4 changes: 0 additions & 4 deletions pool/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions pool/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
14 changes: 0 additions & 14 deletions pool/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ type Hub struct {
connections map[string]uint32
connectionsMtx sync.RWMutex
endpoint *Endpoint
blake256Pad []byte
cacheCh chan CacheUpdateEvent
}

Expand All @@ -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{
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 061234c

Please sign in to comment.