Big refactor of mining pool support, optimization of existing icons
This commit is contained in:
parent
f9aa593f0b
commit
814cd234a9
23 changed files with 772 additions and 1190 deletions
39
src/lib/mining_pool/noderunners/noderunners_pool.cpp
Normal file
39
src/lib/mining_pool/noderunners/noderunners_pool.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
// src/noderunners/noderunners_pool.cpp
|
||||
#include "noderunners_pool.hpp"
|
||||
|
||||
void NodeRunnersPool::prepareRequest(HTTPClient& http) const {
|
||||
// Empty as NodeRunners doesn't need special headers
|
||||
}
|
||||
|
||||
std::string NodeRunnersPool::getApiUrl() const {
|
||||
return "https://pool.noderunners.network/api/v1/users/" + poolUser;
|
||||
}
|
||||
|
||||
PoolStats NodeRunnersPool::parseResponse(const JsonDocument& doc) const {
|
||||
std::string hashrateStr = doc["hashrate1m"].as<std::string>();
|
||||
char unit = hashrateStr.back();
|
||||
std::string value = hashrateStr.substr(0, hashrateStr.size() - 1);
|
||||
|
||||
int multiplier = getHashrateMultiplier(unit);
|
||||
|
||||
return PoolStats{
|
||||
.hashrate = value + std::string(multiplier, '0'),
|
||||
.dailyEarnings = std::nullopt
|
||||
};
|
||||
}
|
||||
|
||||
LogoData NodeRunnersPool::getLogo() const {
|
||||
return LogoData {
|
||||
.data = epd_icons_allArray[6],
|
||||
.width = 122,
|
||||
.height = 122
|
||||
};
|
||||
}
|
||||
|
||||
int NodeRunnersPool::getHashrateMultiplier(char unit) {
|
||||
static const std::unordered_map<char, int> multipliers = {
|
||||
{'Z', 21}, {'E', 18}, {'P', 15}, {'T', 12},
|
||||
{'G', 9}, {'M', 6}, {'K', 3}
|
||||
};
|
||||
return multipliers.at(unit);
|
||||
}
|
20
src/lib/mining_pool/noderunners/noderunners_pool.hpp
Normal file
20
src/lib/mining_pool/noderunners/noderunners_pool.hpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "lib/mining_pool/mining_pool_interface.hpp"
|
||||
#include <icons/icons.h>
|
||||
|
||||
class NodeRunnersPool : public MiningPoolInterface {
|
||||
public:
|
||||
void setPoolUser(const std::string& user) override { poolUser = user; }
|
||||
|
||||
void prepareRequest(HTTPClient& http) const override;
|
||||
std::string getApiUrl() const override;
|
||||
PoolStats parseResponse(const JsonDocument& doc) const override;
|
||||
LogoData getLogo() const override;
|
||||
bool supportsDailyEarnings() const override { return false; }
|
||||
std::string getDailyEarningsLabel() const override { return ""; }
|
||||
|
||||
private:
|
||||
static int getHashrateMultiplier(char unit);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue