Skip to content

Commit 31c0ee3

Browse files
committed
fixup! Optimize ESP8266 miner
1 parent 78ce242 commit 31c0ee3

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

ESP8266_Code/ESP8266_Code.ino

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ void mqttReconnect()
135135
namespace
136136
{
137137
// Change the part in brackets to your Duino-Coin username
138-
const char *DUCO_USER = "USERNAME";
138+
const char *DUCO_USER = "mlesniew";
139139
// Change the part in brackets to your mining key (if you have enabled it in the wallet)
140-
const char *MINER_KEY = "MINING_KEY";
140+
const char *MINER_KEY = "turkawka";
141141
// Change the part in brackets to your WiFi name
142-
const char *SSID = "WIFI_NAME";
142+
const char *SSID = "CyfrowyTapczan";
143143
// Change the part in brackets to your WiFi password
144-
const char *PASSWORD = "WIFI_PASSWORD";
144+
const char *PASSWORD = "bohdanowicza19";
145145
// Change the part in brackets if you want to set a custom miner name (use Auto to autogenerate, None for no name)
146-
const char *RIG_IDENTIFIER = "None";
146+
const char *RIG_IDENTIFIER = "Auto";
147147
// Set to true to use the 160 MHz overclock mode (and not get the first share rejected)
148148
const bool USE_HIGHER_DIFF = true;
149149
// Set to true if you want to host the dashboard page (available on ESPs IP address)
@@ -440,7 +440,7 @@ public:
440440
}
441441

442442
Counter & operator++() {
443-
inc_string(max_digits - 1);
443+
inc_string(buffer + max_digits - 1);
444444
++val;
445445
return *this;
446446
}
@@ -450,18 +450,18 @@ public:
450450
size_t strlen() const { return len; }
451451

452452
protected:
453-
inline void inc_string(int pos) {
454-
if (pos < 0)
455-
return;
456-
457-
if (buffer[pos] < '9') {
458-
buffer[pos]++;
453+
inline void inc_string(char * c) {
454+
// In theory, the line below should be uncommented to avoid writing outside the buffer. In practice however,
455+
// with max_digits set to 10 or more, we can fit all possible unsigned 32-bit integers in the buffer. The
456+
// check is skipped to gain a small extra speed improvement.
457+
// if (c >= buffer) return;
458+
if (*c < '9') {
459+
*c += 1;
459460
} else {
460-
buffer[pos] = '0';
461-
inc_string(pos - 1);
461+
*c = '0';
462+
inc_string(c - 1);
463+
len = max(max_digits - (c - buffer) + 1, len);
462464
}
463-
464-
len = max(max_digits - pos, len);
465465
}
466466

467467
protected:
@@ -777,7 +777,7 @@ void loop() {
777777

778778
String result = "";
779779
if (LED_BLINKING) digitalWrite(LED_BUILTIN, LOW);
780-
for (Counter<8> counter; counter < difficulty; ++counter) {
780+
for (Counter<10> counter; counter < difficulty; ++counter) {
781781
// Difficulty loop
782782
sha1_ctx = sha1_ctx_base;
783783

0 commit comments

Comments
 (0)