2024-12-20 04:00:09 +01:00
|
|
|
// src/noderunners/noderunners_pool.cpp
|
|
|
|
#include "public_pool.hpp"
|
|
|
|
|
2024-12-28 13:40:08 +01:00
|
|
|
std::string PublicPool::getApiUrl() const
|
|
|
|
{
|
2024-12-20 04:00:09 +01:00
|
|
|
return "https://public-pool.io:40557/api/client/" + poolUser;
|
|
|
|
}
|
|
|
|
|
2024-12-28 13:40:08 +01:00
|
|
|
PoolStats PublicPool::parseResponse(const JsonDocument &doc) const
|
|
|
|
{
|
2024-12-20 04:00:09 +01:00
|
|
|
uint64_t totalHashrate = 0;
|
|
|
|
|
2024-12-28 13:40:08 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
for (JsonVariantConst worker : doc["workers"].as<JsonArrayConst>())
|
|
|
|
{
|
|
|
|
totalHashrate += static_cast<uint64_t>(std::llround(worker["hashRate"].as<double>()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const std::exception &e)
|
|
|
|
{
|
|
|
|
Serial.printf("Error parsing %s response: %s\n", getPoolName().c_str(), e.what());
|
|
|
|
return PoolStats{
|
|
|
|
.hashrate = "0",
|
|
|
|
.dailyEarnings = std::nullopt};
|
|
|
|
}
|
2024-12-20 04:00:09 +01:00
|
|
|
|
|
|
|
return PoolStats{
|
|
|
|
.hashrate = std::to_string(totalHashrate),
|
2024-12-28 13:40:08 +01:00
|
|
|
.dailyEarnings = std::nullopt // Public Pool doesn't support daily earnings
|
2024-12-20 04:00:09 +01:00
|
|
|
};
|
|
|
|
}
|