Skip to content

Commit

Permalink
Merge pull request #349 from dwightmulcahy/zerostats
Browse files Browse the repository at this point in the history
zero out mining stats when a reset is done
  • Loading branch information
BitMaker-hub authored May 25, 2024
2 parents 0a22a19 + 331b39f commit a3e52ed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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
6 changes: 5 additions & 1 deletion 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 @@ -54,6 +55,7 @@ void reset_configuration()
{
Serial.println("Erasing Config, restarting");
nvMem.deleteConfig();
resetStat();
wm.resetSettings();
ESP.restart();
}
Expand Down Expand Up @@ -153,7 +155,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("Poolpassword - Optionl", "Pool password", Settings.PoolPassword, 80);

// Add all defined parameters
wm.addParameter(&pool_text_box);
Expand Down

0 comments on commit a3e52ed

Please sign in to comment.