Merge pull request #349 from dwightmulcahy/zerostats

zero out mining stats when a reset is done
This commit is contained in:
BitMaker 2024-05-25 22:39:14 +02:00 committed by GitHub
commit a3e52ed25f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -400,6 +400,13 @@ void saveStat() {
nvs_set_u64(stat_handle, "upTime", upTime + (esp_timer_get_time()/1000000)); 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) void runMonitor(void *name)
{ {

View File

@ -17,6 +17,8 @@ void runStratumWorker(void *name);
void runMiner(void *name); void runMiner(void *name);
String printLocalTime(void); String printLocalTime(void);
void resetStat();
typedef struct{ typedef struct{
uint8_t bytearray_target[32]; uint8_t bytearray_target[32];
uint8_t bytearray_pooltarget[32]; uint8_t bytearray_pooltarget[32];

View File

@ -13,6 +13,7 @@
#include "drivers/storage/SDCard.h" #include "drivers/storage/SDCard.h"
#include "drivers/storage/nvMemory.h" #include "drivers/storage/nvMemory.h"
#include "drivers/storage/storage.h" #include "drivers/storage/storage.h"
#include "mining.h"
#include "timeconst.h" #include "timeconst.h"
@ -54,6 +55,7 @@ void reset_configuration()
{ {
Serial.println("Erasing Config, restarting"); Serial.println("Erasing Config, restarting");
nvMem.deleteConfig(); nvMem.deleteConfig();
resetStat();
wm.resetSettings(); wm.resetSettings();
ESP.restart(); ESP.restart();
} }
@ -153,7 +155,9 @@ void init_WifiManager()
{ {
strcat(checkboxParams, " checked"); 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 // Add all defined parameters
wm.addParameter(&pool_text_box); wm.addParameter(&pool_text_box);