Skip to content

Commit

Permalink
Allow the value 1 for the workerNumberLimit option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stratehm committed Apr 2, 2015
1 parent 31aad85 commit c051341
Show file tree
Hide file tree
Showing 6 changed files with 475 additions and 464 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public class CommandLineOptions {
@Option(name = "--log-real-share-difficulty", usage = "For each share submitted by a worker, the real difficulty is written in the logs. WARN: Only works for SHA256 and Scrypt pools. Should be enabled only for debugging purposes since it is CPU intensive.", handler = BooleanOptionHandler.class)
private Boolean logRealShareDifficulty;

@Option(name = "--worker-number-limit", usage = "Represent the maximum number of workers allowed on the proxy. Only two values are accepted: 256 and 65536. Default to 256. 65536 may lead to some disconnections on some pools (should be rare).")
@Option(name = "--worker-number-limit", usage = "Represent the maximum number of workers allowed on the proxy. Only two values are accepted: 1, 256 and 65536. Default to 256. 65536 may lead to some disconnections on some pools (should be rare).")
private Integer workerNumberLimit;

@Option(name = "--ip-version", usage = "Force the version of IP protocol to use. Valid values are: v4, v6, auto. (auto by default)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,12 @@ private void defineExtranonce1TailSize(Integer workerNumberLimit) {
// If the limit is 65536, the extranonce1 tail size is 2 bytes => 65536
// Else, if not set or with another value, use the default size: 1 byte
// => 256
if (workerNumberLimit != null && workerNumberLimit == 65536) {
extranonce1TailSize = 2;
if (workerNumberLimit != null) {
if (workerNumberLimit == 1) {
extranonce1TailSize = 0;
} else if (workerNumberLimit == 65536) {
extranonce1TailSize = 2;
}
}
}

Expand Down
29 changes: 18 additions & 11 deletions src/main/java/strat/mining/stratum/proxy/pool/Pool.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,20 +664,27 @@ public Integer getWorkerExtranonce2Size() {

private Deque<String> buildTails() {
Deque<String> result = new ConcurrentLinkedDeque<String>();
int nbTails = (int) Math.pow(2, extranonce1TailSize * 8);
int tailNbChars = extranonce1TailSize * 2;
for (int i = 0; i < nbTails; i++) {
String tail = Integer.toHexString(i);

if (tail.length() > extranonce1TailSize * 2) {
tail = tail.substring(0, tailNbChars);
} else {
while (tail.length() < extranonce1TailSize * 2) {
tail = "0" + tail;
// For nb worker limit of 1
if (extranonce1TailSize == 0) {
result.add("");
} else {
// For nb worker limit of 256 and 65536
int nbTails = (int) Math.pow(2, extranonce1TailSize * 8);
int tailNbChars = extranonce1TailSize * 2;
for (int i = 0; i < nbTails; i++) {
String tail = Integer.toHexString(i);

if (tail.length() > extranonce1TailSize * 2) {
tail = tail.substring(0, tailNbChars);
} else {
while (tail.length() < extranonce1TailSize * 2) {
tail = "0" + tail;
}
}
}

result.add(tail);
result.add(tail);
}
}
return result;
}
Expand Down
Loading

0 comments on commit c051341

Please sign in to comment.