Better handling of unexpected pool stats responses, add CKPool
This commit is contained in:
parent
10fe5b5053
commit
b7ff9d8101
10 changed files with 210 additions and 57 deletions
|
@ -1,18 +1,29 @@
|
|||
#include "ocean_pool.hpp"
|
||||
|
||||
void OceanPool::prepareRequest(HTTPClient& http) const {
|
||||
void OceanPool::prepareRequest(HTTPClient &http) const
|
||||
{
|
||||
// Empty as Ocean doesn't need special headers
|
||||
}
|
||||
|
||||
std::string OceanPool::getApiUrl() const {
|
||||
std::string OceanPool::getApiUrl() const
|
||||
{
|
||||
return "https://api.ocean.xyz/v1/statsnap/" + poolUser;
|
||||
}
|
||||
|
||||
PoolStats OceanPool::parseResponse(const JsonDocument& doc) const {
|
||||
return PoolStats{
|
||||
.hashrate = doc["result"]["hashrate_300s"].as<std::string>(),
|
||||
.dailyEarnings = static_cast<int64_t>(
|
||||
doc["result"]["estimated_earn_next_block"].as<float>() * 100000000
|
||||
)
|
||||
};
|
||||
}
|
||||
PoolStats OceanPool::parseResponse(const JsonDocument &doc) const
|
||||
{
|
||||
try
|
||||
{
|
||||
return PoolStats{
|
||||
.hashrate = doc["result"]["hashrate_300s"].as<std::string>(),
|
||||
.dailyEarnings = static_cast<int64_t>(
|
||||
doc["result"]["estimated_earn_next_block"].as<float>() * 100000000)};
|
||||
}
|
||||
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};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue