diff --git a/README.md b/README.md index 3d30a3c..c9ead6f 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,8 @@ Recommended low difficulty share pools: | Pool URL | Port | Web URL | Status | | ----------------- | ----- | -------------------------- | ------------------------------------------------------------------ | | public-pool.io | 21496 | https://web.public-pool.io | Open Source Solo Bitcoin Mining Pool supporting open source miners | -| nerdminers.org | | https://nerdminers.org | Team domain for future pool - Currently pointing to public-pool.io | +| pool.nerdminers.org | 3333 | https://nerdminers.org | The official Nerdminer pool site - Mantained by @golden-guy | | pool.nerdminer.io | 3333 | https://nerdminer.io | Mantained by CHMEX | -| pool.vkbit.com | 3333 | https://vkbit.com/ | Mantained by djerfy - public-pool fork | | pool.pyblock.xyz | 3333 | https://pool.pyblock.xyz/ | Mantained by curly60e | | pool.sethforprivacy.com | 3333 | https://pool.sethforprivacy.com/ | Mantained by @sethforprivacy - public-pool fork | diff --git a/src/mining.cpp b/src/mining.cpp index 1b22107..8e529a9 100644 --- a/src/mining.cpp +++ b/src/mining.cpp @@ -400,6 +400,13 @@ void saveStat() { nvs_set_u64(stat_handle, "upTime", upTime + (esp_timer_get_time()/1000000)); } +void resetStat() { + Serial.printf("[MONITOR] Resetting NVS stats\n"); + templates = hashes = Mhashes = totalKHashes = elapsedKHs = upTime = shares = valids = 0; + best_diff = 0.0; + saveStat(); +} + void runMonitor(void *name) { diff --git a/src/mining.h b/src/mining.h index 2eff707..a1adf14 100644 --- a/src/mining.h +++ b/src/mining.h @@ -17,6 +17,8 @@ void runStratumWorker(void *name); void runMiner(void *name); String printLocalTime(void); +void resetStat(); + typedef struct{ uint8_t bytearray_target[32]; uint8_t bytearray_pooltarget[32]; diff --git a/src/monitor.h b/src/monitor.h index 8e25146..dfe3791 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -12,8 +12,8 @@ //Time update period #define UPDATE_PERIOD_h 5 -//API BTC price -#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USD" +//API BTC price (Update to USDT cus it's more liquidity and flow price updade) +#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USDT" #define UPDATE_BTC_min 1 //API Block height diff --git a/src/utils.cpp b/src/utils.cpp index 58df0ca..20120be 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -136,21 +136,37 @@ bool checkValid(unsigned char* hash, unsigned char* target) { return valid; } +/** + * get random extranonce2 +*/ +void getRandomExtranonce2(int extranonce2_size, char *extranonce2) { + uint8_t b0, b1, b2, b3; + + b0 = rand() % 256; + b1 = rand() % 256; + b2 = rand() % 256; + b3 = rand() % 256; + + unsigned long extranonce2_number = b3 << 24 | b2 << 16 | b1 << 8 | b0; + + char format[] = "%00x"; + + sprintf(&format[1], "%02dx", extranonce2_size * 2); + sprintf(extranonce2, format, extranonce2_number); +} + +/** + * get linear extranonce2 +*/ void getNextExtranonce2(int extranonce2_size, char *extranonce2) { - unsigned long extranonce2_number = strtoul(extranonce2, NULL, 10); + extranonce2_number++; - - memset(extranonce2, '0', 2 * extranonce2_size); - if (extranonce2_number > long(pow(10, 2 * extranonce2_size))) { - return; - } - - char next_extranounce2[2 * extranonce2_size + 1]; - memset(extranonce2, '0', 2 * extranonce2_size); - ultoa(extranonce2_number, next_extranounce2, 10); - memcpy(extranonce2 + (2 * extranonce2_size) - long(log10(extranonce2_number)) - 1 , next_extranounce2, strlen(next_extranounce2)); - extranonce2[2 * extranonce2_size] = 0; + + char format[] = "%00x"; + + sprintf(&format[1], "%02dx", extranonce2_size * 2); + sprintf(extranonce2, format, extranonce2_number); } miner_data init_miner_data(void){ diff --git a/src/wManager.cpp b/src/wManager.cpp index 2f40d85..e91f85b 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -13,6 +13,7 @@ #include "drivers/storage/SDCard.h" #include "drivers/storage/nvMemory.h" #include "drivers/storage/storage.h" +#include "mining.h" #include "timeconst.h" @@ -62,6 +63,7 @@ void reset_configuration() { Serial.println("Erasing Config, restarting"); nvMem.deleteConfig(); + resetStat(); wm.resetSettings(); ESP.restart(); } @@ -165,10 +167,9 @@ void init_WifiManager() { strcat(checkboxParams, " checked"); } - WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Track Uptime, Best Diff, Total Hashes in device Flash memory. (Experimental)", "T", 2, checkboxParams, WFM_LABEL_AFTER); - + WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Save mining statistics to flash memory.", "T", 2, checkboxParams, WFM_LABEL_AFTER); // Text box (String) - 80 characters maximum - WiFiManagerParameter password_text_box("PoolpasswordOptionl", "Pool password (optional)", Settings.PoolPassword, 80); + WiFiManagerParameter password_text_box("Poolpassword - Optionl", "Pool password", Settings.PoolPassword, 80); // Add all defined parameters wm.addParameter(&pool_text_box);