2024-12-20 01:08:03 +01:00
|
|
|
// src/noderunners/noderunners_pool.cpp
|
|
|
|
#include "noderunners_pool.hpp"
|
|
|
|
|
2024-12-20 04:00:09 +01:00
|
|
|
void NoderunnersPool::prepareRequest(HTTPClient& http) const {
|
2024-12-20 01:08:03 +01:00
|
|
|
// Empty as NodeRunners doesn't need special headers
|
|
|
|
}
|
|
|
|
|
2024-12-20 04:00:09 +01:00
|
|
|
std::string NoderunnersPool::getApiUrl() const {
|
2024-12-20 01:08:03 +01:00
|
|
|
return "https://pool.noderunners.network/api/v1/users/" + poolUser;
|
|
|
|
}
|
|
|
|
|
2024-12-20 04:00:09 +01:00
|
|
|
PoolStats NoderunnersPool::parseResponse(const JsonDocument& doc) const {
|
2024-12-20 01:08:03 +01:00
|
|
|
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
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-12-20 04:00:09 +01:00
|
|
|
LogoData NoderunnersPool::getLogo() const {
|
2024-12-20 01:08:03 +01:00
|
|
|
return LogoData {
|
|
|
|
.data = epd_icons_allArray[6],
|
|
|
|
.width = 122,
|
|
|
|
.height = 122
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-12-20 04:00:09 +01:00
|
|
|
int NoderunnersPool::getHashrateMultiplier(char unit) {
|
|
|
|
if (unit == '0')
|
|
|
|
return 0;
|
|
|
|
|
2024-12-20 01:08:03 +01:00
|
|
|
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);
|
|
|
|
}
|