Skip to content

Commit

Permalink
pool: Remove code related to Innosilicon D9.
Browse files Browse the repository at this point in the history
The Innosilicon D9 is no longer supported since it mines blake256 and
the hash algorithm is now blake3.
  • Loading branch information
davecgh committed Sep 29, 2023
1 parent 41413e1 commit 7bd28ff
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 173 deletions.
5 changes: 0 additions & 5 deletions internal/gui/assets/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ <h2>Identify the Miner</h2>
</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://mining.obelisk.tech/downloads/firmware/obelisk-sc1-v1.3.2.img">Obelisk&nbsp;DCR1</a>
Expand Down
40 changes: 0 additions & 40 deletions pool/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,42 +909,6 @@ func hexReversed(in string) (string, error) {
return buf.String(), nil
}

// 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())
}

// handleCPUWork prepares work for the cpu miner.
func (c *Client) handleCPUWork(req *Request) {
const miner = "CPU"
Expand Down Expand Up @@ -1161,10 +1125,6 @@ func (c *Client) send() {
c.handleCPUWork(req)
log.Tracef("%s notified of new work", id)

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

case ObeliskDCR1:
c.handleObeliskDCR1Work(req)
log.Tracef("%s notified of new work", id)
Expand Down
100 changes: 0 additions & 100 deletions pool/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,43 +412,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("expected a non-error response, got %s", resp.Error.Message)
}

// Ensure an Innosilicon D9 client receives a valid non-error
// response when a valid subscribe request is sent.
err = setMiner(client, InnosiliconD9)
if err != nil {
t.Fatalf("unexpected set miner error: %v", err)
}

id++
d9, d9Version := splitMinerID(d9ID)
r = SubscribeRequest(&id, userAgent(d9, d9Version), "")
err = sE.Encode(r)
if err != nil {
t.Fatalf("[Encode] unexpected error: %v", err)
}
select {
case <-client.ctx.Done():
t.Fatalf("client context done: %v", err)
case data = <-recvCh:
}
msg, mType, err = IdentifyMessage(data)
if err != nil {
t.Fatalf("[IdentifyMessage] unexpected error: %v", err)
}
if mType != ResponseMessage {
t.Fatalf("expected a subscribe response message, got %v", mType)
}
resp, ok = msg.(*Response)
if !ok {
t.Fatalf("expected subsribe response with id %d, got %d", *r.ID, resp.ID)
}
if resp.ID != *r.ID {
t.Fatalf("expected subscribe response with id %d, got %d", *r.ID, resp.ID)
}
if resp.Error != nil {
t.Fatalf("expected a non-error response, got %s", resp.Error.Message)
}

// Ensure a CPU client receives a valid non-error response when a
// valid subscribe request is sent.
err = setMiner(client, CPU)
Expand Down Expand Up @@ -581,35 +544,6 @@ func testClientMessageHandling(t *testing.T) {
client.lastWorkTime)
}

// Send a work notification to an Innosilicon D9 client.
err = setMiner(client, InnosiliconD9)
if err != nil {
t.Fatalf("unexpected set miner error: %v", err)
}

select {
case <-client.ctx.Done():
t.Fatalf("client context done: %v", err)
case client.ch <- r:
}

// Ensure the work notification received is unique to the D9.
var d9Work []byte
select {
case <-client.ctx.Done():
t.Fatalf("client context done: %v", err)
case d9Work = <-recvCh:
}
if bytes.Equal(cpuWork, d9Work) {
t.Fatalf("expected innosilicond9 work to be different from cpu work")
}

// Claim a weighted share for the Innosilicon D9 client.
err = client.claimWeightedShare()
if err != nil {
t.Fatalf("[claimWeightedShare (D9)] unexpected error: %v", err)
}

// Send a work notification to an Obelisk DCR1 client.
err = setMiner(client, ObeliskDCR1)
if err != nil {
Expand Down Expand Up @@ -938,40 +872,6 @@ func testClientMessageHandling(t *testing.T) {
t.Fatalf("expected no-error work submission response, got %v", resp.Error)
}

// Ensure the pool processes Innosilicon D9 work submissions.
err = setMiner(client, InnosiliconD9)
if err != nil {
t.Fatalf("unexpected set miner error: %v", err)
}

id++
sub = SubmitWorkRequest(&id, "tcl", job.UUID, "00000000",
"954cee5d", "6ddf0200")
err = sE.Encode(sub)
if err != nil {
t.Fatalf("[Encode] unexpected error: %v", err)
}
var d9Sub []byte
select {
case <-client.ctx.Done():
t.Fatalf("client context done: %v", err)
case d9Sub = <-recvCh:
}
msg, mType, err = IdentifyMessage(d9Sub)
if err != nil {
t.Fatalf("[IdentifyMessage] unexpected error: %v", err)
}
if mType != ResponseMessage {
t.Fatalf("expected a response message, got %v", mType)
}
resp, ok = msg.(*Response)
if !ok {
t.Fatalf("unable to cast message as response")
}
if resp.ID != *sub.ID {
t.Fatalf("expected a response with id %d, got %d", *sub.ID, resp.ID)
}

// Ensure the pool processes Obelisk DCR1 work submissions.
err = setMiner(client, ObeliskDCR1)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pool/difficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
// Supported mining clients.
const (
CPU = "cpu"
InnosiliconD9 = "innosilicond9"
ObeliskDCR1 = "obeliskdcr1"
NiceHashValidator = "nicehash"
)
Expand All @@ -30,7 +29,6 @@ var (
minerHashes = map[string]*big.Int{
CPU: new(big.Int).SetInt64(5e3),
ObeliskDCR1: new(big.Int).SetInt64(1.2e12),
InnosiliconD9: new(big.Int).SetInt64(2.4e12),
NiceHashValidator: new(big.Int).SetInt64(20e10),
}
)
Expand Down
20 changes: 0 additions & 20 deletions pool/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,26 +626,6 @@ func GenerateSolvedBlockHeader(headerE string, extraNonce1E string,
copy(headerEB[288:296], []byte(extraNonce1E))
copy(headerEB[296:304], []byte(extraNonce2E))

// The Innosilicon D9 respects the extraNonce2Size specified in the
// mining.subscribe response sent to it. The extraNonce2 value submitted is
// exclusively the extraNonce2. The nTime and nonce values submitted are
// big endian, they have to be reversed to little endian before header
// reconstruction.
case InnosiliconD9:
nTimeERev, err := hexReversed(nTimeE)
if err != nil {
return nil, err
}
copy(headerEB[272:280], []byte(nTimeERev))

nonceERev, err := hexReversed(nonceE)
if err != nil {
return nil, err
}
copy(headerEB[280:288], []byte(nonceERev))
copy(headerEB[288:296], []byte(extraNonce1E))
copy(headerEB[296:304], []byte(extraNonce2E))

default:
desc := fmt.Sprintf("miner %s is unknown", miner)
return nil, errs.MsgError(errs.MinerUnknown, desc)
Expand Down
3 changes: 0 additions & 3 deletions pool/miner_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var (

cpuID = "cpuminer/1.0.0"
dcr1ID = "cgminer/4.10.0"
d9ID = "sgminer/4.4.2"
nhID = "NiceHash/1.0.0"
)

Expand Down Expand Up @@ -45,12 +44,10 @@ func generateMinerIDs() map[string]*minerIDPair {
ids := make(map[string]*minerIDPair)
cpu := newMinerIDPair(cpuID, CPU)
obelisk := newMinerIDPair(dcr1ID, ObeliskDCR1)
innosilicon := newMinerIDPair(d9ID, InnosiliconD9)
nicehash := newMinerIDPair(nhID, NiceHashValidator)

ids[cpu.id] = cpu
ids[obelisk.id] = obelisk
ids[innosilicon.id] = innosilicon
ids[nicehash.id] = nicehash
return ids
}
Expand Down
5 changes: 2 additions & 3 deletions pool/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (
//
// (Hash of Miner X * Weight of LHM)/ Hash of LHM
var ShareWeights = map[string]*big.Rat{
CPU: new(big.Rat).SetFloat64(1.0), // Reserved for testing.
ObeliskDCR1: new(big.Rat).SetFloat64(1.0),
InnosiliconD9: new(big.Rat).SetFloat64(2.182),
CPU: new(big.Rat).SetFloat64(1.0), // Reserved for testing.
ObeliskDCR1: new(big.Rat).SetFloat64(1.0),
}

// shareID generates a unique share id using the provided account, creation
Expand Down

0 comments on commit 7bd28ff

Please sign in to comment.