Compare commits

..

No commits in common. "f9aa593f0b39b6889c041288c982b39932730cb6" and "8f9307d1e4de2b92fbc38f16e6599f495a50754b" have entirely different histories.

3 changed files with 13 additions and 11 deletions

View file

@ -58,8 +58,11 @@
#define DEFAULT_BITAXE_ENABLED false
#define DEFAULT_BITAXE_HOSTNAME "bitaxe1"
#define MINING_POOL_NAME_OCEAN "ocean"
#define MINING_POOL_NAME_BRAIINS "braiins"
#define DEFAULT_MINING_POOL_STATS_ENABLED false
#define DEFAULT_MINING_POOL_NAME "ocean"
#define DEFAULT_MINING_POOL_NAME MINING_POOL_NAME_OCEAN
#define DEFAULT_MINING_POOL_USER "38Qkkei3SuF1Eo45BaYmRHUneRD54yyTFy" // Random actual Ocean hasher
#define DEFAULT_ZAP_NOTIFY_ENABLED false

View file

@ -2,7 +2,6 @@
TaskHandle_t miningPoolStatsFetchTaskHandle;
std::string miningPoolName;
std::string miningPoolStatsHashrate;
int miningPoolStatsDailyEarnings;
@ -26,21 +25,19 @@ void taskMiningPoolStatsFetch(void *pvParameters)
http.setUserAgent(USER_AGENT);
String miningPoolStatsApiUrl;
miningPoolName = preferences.getString("miningPoolName", DEFAULT_MINING_POOL_NAME).c_str();
std::string httpHeaderKey = "";
std::string httpHeaderValue;
if (miningPoolName == "ocean") {
if (preferences.getString("miningPoolName", DEFAULT_MINING_POOL_NAME) == MINING_POOL_NAME_OCEAN) {
miningPoolStatsApiUrl = "https://api.ocean.xyz/v1/statsnap/" + preferences.getString("miningPoolUser", DEFAULT_MINING_POOL_USER);
}
else if (miningPoolName == "braiins") {
else if (preferences.getString("miningPoolName", DEFAULT_MINING_POOL_NAME) == MINING_POOL_NAME_BRAIINS) {
miningPoolStatsApiUrl = "https://pool.braiins.com/accounts/profile/json/btc/";
httpHeaderKey = "Pool-Auth-Token";
httpHeaderValue = preferences.getString("miningPoolUser", DEFAULT_MINING_POOL_USER).c_str();
}
else
{
// Unknown mining pool / missing implementation
Serial.println("Unknown mining pool: \"" + preferences.getString("miningPoolName", DEFAULT_MINING_POOL_NAME) + "\"");
continue;
}
@ -58,11 +55,13 @@ void taskMiningPoolStatsFetch(void *pvParameters)
JsonDocument doc;
deserializeJson(doc, payload);
if (miningPoolName == "ocean") {
Serial.println(doc.as<String>());
if (preferences.getString("miningPoolName", DEFAULT_MINING_POOL_NAME) == MINING_POOL_NAME_OCEAN) {
miningPoolStatsHashrate = doc["result"]["hashrate_300s"].as<std::string>();
miningPoolStatsDailyEarnings = int(doc["result"]["estimated_earn_next_block"].as<float>() * 100000000);
}
else if (miningPoolName == "braiins") {
else if (preferences.getString("miningPoolName", DEFAULT_MINING_POOL_NAME) == MINING_POOL_NAME_BRAIINS) {
// Reports hashrate in specific hashrate units (e.g. Gh/s); we want raw total hashes per second.
std::string hashrateUnit = doc["btc"]["hash_rate_unit"].as<std::string>();
int multiplier = 0;

View file

@ -60,8 +60,8 @@ const PROGMEM int SCREEN_MARKET_CAP = 30;
const PROGMEM int SCREEN_BITAXE_HASHRATE = 80;
const PROGMEM int SCREEN_BITAXE_BESTDIFF = 81;
const PROGMEM int SCREEN_MINING_POOL_STATS_HASHRATE = 70;
const PROGMEM int SCREEN_MINING_POOL_STATS_EARNINGS = 71;
const PROGMEM int SCREEN_MINING_POOL_STATS_HASHRATE = 85;
const PROGMEM int SCREEN_MINING_POOL_STATS_EARNINGS = 86;
const PROGMEM int SCREEN_COUNTDOWN = 98;
const PROGMEM int SCREEN_CUSTOM = 99;