Use double precision for pool difficulty
This commit is contained in:
parent
3872bd7a08
commit
f15715f3f3
@ -111,7 +111,7 @@ void runStratumWorker(void *name) {
|
||||
|
||||
// connect to pool
|
||||
|
||||
float currentPoolDifficulty = atof(DEFAULT_DIFFICULTY);
|
||||
double currentPoolDifficulty = DEFAULT_DIFFICULTY;
|
||||
|
||||
while(true) {
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
// Mining
|
||||
#define MAX_NONCE 5000000U
|
||||
#define TARGET_NONCE 471136297U
|
||||
#define DEFAULT_DIFFICULTY "1e-9"
|
||||
#define DEFAULT_DIFFICULTY 1e-9
|
||||
#define KEEPALIVE_TIME_ms 30000
|
||||
#define POOLINACTIVITY_TIME_ms 60000
|
||||
|
||||
@ -21,7 +21,7 @@ typedef struct{
|
||||
uint8_t bytearray_pooltarget[32];
|
||||
uint8_t merkle_result[32];
|
||||
uint8_t bytearray_blockheader[80];
|
||||
float poolDifficulty;
|
||||
double poolDifficulty;
|
||||
bool inRun;
|
||||
bool newJob;
|
||||
bool newJob2;
|
||||
|
@ -216,7 +216,7 @@ bool tx_mining_submit(WiFiClient& client, mining_subscribe mWorker, mining_job m
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parse_mining_set_difficulty(String line, float& difficulty)
|
||||
bool parse_mining_set_difficulty(String line, double& difficulty)
|
||||
{
|
||||
Serial.println(" Parsing Method [SET DIFFICULTY]");
|
||||
if(!verifyPayload(&line)) return false;
|
||||
@ -226,8 +226,8 @@ bool parse_mining_set_difficulty(String line, float& difficulty)
|
||||
if (error) return false;
|
||||
if (!doc.containsKey("params")) return false;
|
||||
|
||||
Serial.print(" difficulty: "); Serial.println((float)doc["params"][0],12);
|
||||
difficulty = (float)doc["params"][0];
|
||||
Serial.print(" difficulty: "); Serial.println((double)doc["params"][0],12);
|
||||
difficulty = (double)doc["params"][0];
|
||||
|
||||
#ifdef DEBUG_MINING
|
||||
Serial.print(" job_id: "); Serial.println(job_id);
|
||||
@ -236,12 +236,12 @@ bool parse_mining_set_difficulty(String line, float& difficulty)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool tx_suggest_difficulty(WiFiClient& client, const char * difficulty)
|
||||
bool tx_suggest_difficulty(WiFiClient& client, double difficulty)
|
||||
{
|
||||
char payload[BUFFER] = {0};
|
||||
|
||||
id = getNextId(id);
|
||||
sprintf(payload, "{\"id\": %d, \"method\": \"mining.suggest_difficulty\", \"params\": [%s]}\n", id, difficulty);
|
||||
sprintf(payload, "{\"id\": %d, \"method\": \"mining.suggest_difficulty\", \"params\": [%.10g]}\n", id, difficulty);
|
||||
|
||||
Serial.print(" Sending : "); Serial.print(payload);
|
||||
return client.print(payload);
|
||||
|
@ -62,8 +62,8 @@ bool parse_mining_notify(String line, mining_job& mJob);
|
||||
bool tx_mining_submit(WiFiClient& client, mining_subscribe mWorker, mining_job mJob, unsigned long nonce);
|
||||
|
||||
//Difficulty Methods
|
||||
bool tx_suggest_difficulty(WiFiClient& client, const char * difficulty);
|
||||
bool parse_mining_set_difficulty(String line, float& difficulty);
|
||||
bool tx_suggest_difficulty(WiFiClient& client, double difficulty);
|
||||
bool parse_mining_set_difficulty(String line, double& difficulty);
|
||||
|
||||
|
||||
#endif // STRATUM_API_H
|
@ -155,7 +155,7 @@ miner_data init_miner_data(void){
|
||||
|
||||
miner_data newMinerData;
|
||||
|
||||
newMinerData.poolDifficulty = atof(DEFAULT_DIFFICULTY);
|
||||
newMinerData.poolDifficulty = DEFAULT_DIFFICULTY;
|
||||
newMinerData.inRun = false;
|
||||
newMinerData.newJob = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user