Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pool: Remove code related to unsupported ASICs. #400

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions internal/gui/assets/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,12 @@ <h1>Mining Pool Overview</h1>
</div>
<div class="carousel-text col-lg-8 col-12 px-4">
<h2>Identify the Miner</h2>
<p> The pool currently supports the miners and their associated linked firmwares listed
below:
<p>The pool currently supports the miners below:
</p>
<div class="d-flex flex-row">
<ul>
<li>
<a
rel="noopener noreferrer"
href="http://www.innosilicon.com.cn/download/d9_20190521_071217.swu">Innosilicon&nbsp;D9</a>
</li>
<li><a
rel="noopener noreferrer"
href="https://file12.bitmain.com/shop-product/firmware/Antminer%20DR3/Firmware/007201907271437364778LxDsS1k06AF/Antminer-DR3-201907161805-410M.tar.gz">Antminer&nbsp;DR3</a>
</li>
<li><a
rel="noopener noreferrer"
href="https://mining.obelisk.tech/downloads/firmware/obelisk-sc1-v1.3.2.img">Obelisk&nbsp;DCR1</a>
</li>
<li><a
rel="noopener noreferrer"
href="https://file12.bitmain.com/shop-product/firmware/Antminer%20DR5/Firmware/00720190727142534231Ato7d2300650/Antminer-DR5-201907161801-600M.tar.gz">Antminer&nbsp;DR5</a>
</li>
<li><a
rel="noopener noreferrer"
href="https://github.com/decred/dcrpool/files/5651882/upgrade-whatsminer-h6-20190404.18.zip">Whatsminer&nbsp;D1</a>
Coming Soon!
</li>
</ul>
</div>
Expand Down
211 changes: 0 additions & 211 deletions pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,38 +413,6 @@ func (c *Client) handleSubscribeRequest(req *Request, allowed bool) error {

var resp *Response
switch miner {
case ObeliskDCR1:
// The DCR1 is not fully complaint with the stratum spec.
// It uses a 4-byte extraNonce2 regardless of the
// extraNonce2Size provided.
resp = SubscribeResponse(*req.ID, nid, c.extraNonce1,
ExtraNonce2Size, nil)

case AntminerDR3:
// The DR3 is not fully complaint with the stratum spec.
// It uses an 8-byte extraNonce2 regardless of the
// extraNonce2Size provided.
//
// The extraNonce1 is appended to the extraNonce2 in the
// extraNonce2 value returned in mining.submit. As a result,
// the extraNonce1 sent in mining.subscribe response is formatted as:
// extraNonce2 space (8-byte) + miner's extraNonce1 (4-byte)
paddedExtraNonce1 := strings.Repeat("0", 16) + c.extraNonce1
resp = SubscribeResponse(*req.ID, nid, paddedExtraNonce1, 8, nil)

case WhatsminerD1:
// The D1 is not fully complaint with the stratum spec.
// It uses a 4-byte extraNonce2 regardless of the
// extraNonce2Size provided.
//
// The extraNonce1 is appended to the extraNonce2 in the
// extraNonce2 value returned in mining.submit. As a result,
// the extraNonce1 sent in mining.subscribe response is formatted as:
// extraNonce2 space (4-byte) + miner's extraNonce1 (4-byte)
paddedExtraNonce1 := strings.Repeat("0", 8) + c.extraNonce1
resp = SubscribeResponse(*req.ID, nid, paddedExtraNonce1,
ExtraNonce2Size, nil)

default:
// The default case handles mining clients that support the
// stratum spec and respect the extraNonce2Size provided.
Expand Down Expand Up @@ -905,132 +873,6 @@ func (c *Client) process() {
}
}

// reversePrevBlockWords reverses each 4-byte word in the provided hex encoded
// previous block hash.
func reversePrevBlockWords(hashE string) string {
var buf bytes.Buffer
for i := 0; i < len(hashE); i += 8 {
_, _ = buf.WriteString(hashE[i+6 : i+8])
_, _ = buf.WriteString(hashE[i+4 : i+6])
_, _ = buf.WriteString(hashE[i+2 : i+4])
_, _ = buf.WriteString(hashE[i : i+2])
}
return buf.String()
}

// hexReversed reverses a hex string.
func hexReversed(in string) (string, error) {
const funcName = "hexReversed"
if len(in)%2 != 0 {
desc := fmt.Sprintf("%s: expected even hex input length, got %d",
funcName, len(in))
return "", errs.PoolError(errs.HexLength, desc)
}
var buf bytes.Buffer
for i := len(in) - 1; i > -1; i -= 2 {
_ = buf.WriteByte(in[i-1])
_ = buf.WriteByte(in[i])
}
return buf.String(), nil
}

// handleAntminerDR3 prepares work notifications for the Antminer DR3.
func (c *Client) handleAntminerDR3Work(req *Request) {
miner := "AntminerDR3"
jobID, prevBlock, genTx1, genTx2, blockVersion, nBits, nTime,
cleanJob, err := ParseWorkNotification(req)
if err != nil {
log.Errorf("%s: %v", miner, err)
}

// The DR3 requires the nBits and nTime fields of a mining.notify message
// as big endian.
nBits, err = hexReversed(nBits)
if err != nil {
log.Errorf("%s: %v for nBits", miner, err)
c.cancel()
return
}
nTime, err = hexReversed(nTime)
if err != nil {
log.Errorf("%s: %v for nTime", miner, err)
c.cancel()
return
}
prevBlockRev := reversePrevBlockWords(prevBlock)
workNotif := WorkNotification(jobID, prevBlockRev,
genTx1, genTx2, blockVersion, nBits, nTime, cleanJob)
err = c.encoder.Encode(workNotif)
if err != nil {
log.Errorf("%s: work encoding error, %v", miner, err)
c.cancel()
return
}

atomic.StoreInt64(&c.lastWorkTime, time.Now().Unix())
}

// handleInnosiliconD9Work prepares work notifications for the Innosilicon D9.
func (c *Client) handleInnosiliconD9Work(req *Request) {
miner := "InnosiliconD9"
jobID, prevBlock, genTx1, genTx2, blockVersion, nBits, nTime,
cleanJob, err := ParseWorkNotification(req)
if err != nil {
log.Errorf("%s: %v", miner, err)
}

// The D9 requires the nBits and nTime fields of a mining.notify message
// as big endian.
nBits, err = hexReversed(nBits)
if err != nil {
log.Errorf("%s: %v for nBits", miner, err)
c.cancel()
return
}
nTime, err = hexReversed(nTime)
if err != nil {
log.Errorf("%s: %v for nTime", miner, err)
c.cancel()
return
}
prevBlockRev := reversePrevBlockWords(prevBlock)
workNotif := WorkNotification(jobID, prevBlockRev,
genTx1, genTx2, blockVersion, nBits, nTime, cleanJob)
err = c.encoder.Encode(workNotif)
if err != nil {
log.Errorf("%s: work encoding error, %v", miner, err)
c.cancel()
return
}

atomic.StoreInt64(&c.lastWorkTime, time.Now().Unix())
}

// handleWhatsminerD1Work prepares work notifications for the Whatsminer D1.
func (c *Client) handleWhatsminerD1Work(req *Request) {
miner := "WhatsminerD1"
jobID, prevBlock, genTx1, genTx2, blockVersion, nBits, nTime,
cleanJob, err := ParseWorkNotification(req)
if err != nil {
log.Errorf("%s: %v", miner, err)
}

// The D1 requires the nBits and nTime fields of a mining.notify message
// as little endian. Since they're already in the preferred format there
// is no need to reverse bytes for nBits and nTime.
prevBlockRev := reversePrevBlockWords(prevBlock)
workNotif := WorkNotification(jobID, prevBlockRev,
genTx1, genTx2, blockVersion, nBits, nTime, cleanJob)
err = c.encoder.Encode(workNotif)
if err != nil {
log.Errorf("%s: work encoding error: %v", miner, err)
c.cancel()
return
}

atomic.StoreInt64(&c.lastWorkTime, time.Now().Unix())
}

// handleCPUWork prepares work for the cpu miner.
func (c *Client) handleCPUWork(req *Request) {
const miner = "CPU"
Expand All @@ -1044,43 +886,6 @@ func (c *Client) handleCPUWork(req *Request) {
atomic.StoreInt64(&c.lastWorkTime, time.Now().Unix())
}

// handleObeliskDCR1Work prepares work for the Obelisk DCR1.
func (c *Client) handleObeliskDCR1Work(req *Request) {
miner := "ObeliskDCR1"
jobID, prevBlock, genTx1, genTx2, blockVersion, nBits, nTime,
cleanJob, err := ParseWorkNotification(req)
if err != nil {
log.Errorf("%s: %v", miner, err)
}

// The DCR1 requires the nBits and nTime fields of a mining.notify message
// as big endian.
nBits, err = hexReversed(nBits)
if err != nil {
log.Errorf("%s: %v for nBits", miner, err)
c.cancel()
return
}
nTime, err = hexReversed(nTime)
if err != nil {
log.Errorf("%s: %v for nTime", miner, err)
c.cancel()
return
}

prevBlockRev := reversePrevBlockWords(prevBlock)
workNotif := WorkNotification(jobID, prevBlockRev,
genTx1, genTx2, blockVersion, nBits, nTime, cleanJob)
err = c.encoder.Encode(workNotif)
if err != nil {
log.Errorf("%s: work encoding error, %v", miner, err)
c.cancel()
return
}

atomic.StoreInt64(&c.lastWorkTime, time.Now().Unix())
}

// setHashRate updates the client's hash rate.
func (c *Client) setHashRate(hash *big.Rat) {
c.hashRateMtx.Lock()
Expand Down Expand Up @@ -1247,22 +1052,6 @@ func (c *Client) send() {
c.handleCPUWork(req)
log.Tracef("%s notified of new work", id)

case AntminerDR3, AntminerDR5:
c.handleAntminerDR3Work(req)
log.Tracef("%s notified of new work", id)

case InnosiliconD9:
c.handleInnosiliconD9Work(req)
log.Tracef("%s notified of new work", id)

case WhatsminerD1:
c.handleWhatsminerD1Work(req)
log.Tracef("%s notified of new work", id)

case ObeliskDCR1:
c.handleObeliskDCR1Work(req)
log.Tracef("%s notified of new work", id)

default:
log.Errorf("unknown miner for client: %s, "+
"message: %s", miner, req.String())
Expand Down
Loading