Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BitMaker-hub committed May 25, 2024
2 parents 387114c + a3e52ed commit 8587096
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 19 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
7 changes: 7 additions & 0 deletions src/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down
2 changes: 2 additions & 0 deletions src/mining.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions src/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 28 additions & 12 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
7 changes: 4 additions & 3 deletions src/wManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down Expand Up @@ -62,6 +63,7 @@ void reset_configuration()
{
Serial.println("Erasing Config, restarting");
nvMem.deleteConfig();
resetStat();
wm.resetSettings();
ESP.restart();
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8587096

Please sign in to comment.