2024-12-17 20:17:21 -06:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include <HTTPClient.h>
|
2025-01-05 20:24:13 +01:00
|
|
|
#include <utils.hpp>
|
|
|
|
#include <memory>
|
2024-12-17 20:17:21 -06:00
|
|
|
|
|
|
|
#include "lib/config.hpp"
|
|
|
|
#include "lib/shared.hpp"
|
2025-01-05 20:24:13 +01:00
|
|
|
#include "lib/mining_pool/mining_pool_interface.hpp"
|
|
|
|
#include "mining_pool/pool_factory.hpp"
|
2024-12-17 20:17:21 -06:00
|
|
|
|
2025-01-05 20:24:13 +01:00
|
|
|
class MiningPoolStatsFetch {
|
|
|
|
public:
|
|
|
|
static MiningPoolStatsFetch& getInstance() {
|
|
|
|
static MiningPoolStatsFetch instance;
|
|
|
|
return instance;
|
|
|
|
}
|
2024-12-17 20:17:21 -06:00
|
|
|
|
2025-01-05 20:24:13 +01:00
|
|
|
void setup();
|
|
|
|
std::string getHashRate() const;
|
|
|
|
int getDailyEarnings() const;
|
|
|
|
TaskHandle_t getTaskHandle() const { return taskHandle; }
|
|
|
|
static void taskWrapper(void* pvParameters);
|
|
|
|
static void downloadLogoTaskWrapper(void* pvParameters);
|
|
|
|
|
|
|
|
// Pool interface methods
|
|
|
|
MiningPoolInterface* getPool();
|
|
|
|
const MiningPoolInterface* getPool() const;
|
|
|
|
LogoData getLogo() const;
|
2024-12-17 20:17:21 -06:00
|
|
|
|
2025-01-05 20:24:13 +01:00
|
|
|
private:
|
|
|
|
MiningPoolStatsFetch() = default;
|
|
|
|
~MiningPoolStatsFetch() = default;
|
|
|
|
MiningPoolStatsFetch(const MiningPoolStatsFetch&) = delete;
|
|
|
|
MiningPoolStatsFetch& operator=(const MiningPoolStatsFetch&) = delete;
|
2024-12-20 01:08:03 +01:00
|
|
|
|
2025-01-05 20:24:13 +01:00
|
|
|
void task();
|
|
|
|
void downloadLogoTask();
|
|
|
|
|
|
|
|
TaskHandle_t taskHandle = nullptr;
|
|
|
|
std::string hashrate;
|
|
|
|
int dailyEarnings = 0;
|
|
|
|
std::unique_ptr<MiningPoolInterface> currentPool;
|
|
|
|
};
|