From 65b08c47332a36f4bdc7c7e9af0065cc7d0c1aba Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Thu, 20 Jul 2023 18:45:29 +0200 Subject: [PATCH] Fix debug logging --- src/stratum.cpp | 22 +++++++++------------- src/utils.cpp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/stratum.cpp b/src/stratum.cpp index a3c9a0e..4970656 100644 --- a/src/stratum.cpp +++ b/src/stratum.cpp @@ -176,15 +176,15 @@ bool parse_mining_notify(String line, mining_job& mJob) mJob.clean_jobs = doc["params"][8]; //bool #ifdef DEBUG_MINING - Serial.print(" job_id: "); Serial.println(job_id); - Serial.print(" prevhash: "); Serial.println(prev_block_hash); - Serial.print(" coinb1: "); Serial.println(coinb1); - Serial.print(" coinb2: "); Serial.println(coinb2); - Serial.print(" merkle_branch size: "); Serial.println(merkle_branches.size()); - Serial.print(" version: "); Serial.println(version); - Serial.print(" nbits: "); Serial.println(nbits); - Serial.print(" ntime: "); Serial.println(ntime); - Serial.print(" clean_jobs: "); Serial.println(clean_jobs); + Serial.print(" job_id: "); Serial.println(mJob.job_id); + Serial.print(" prevhash: "); Serial.println(mJob.prev_block_hash); + Serial.print(" coinb1: "); Serial.println(mJob.coinb1); + Serial.print(" coinb2: "); Serial.println(mJob.coinb2); + Serial.print(" merkle_branch size: "); Serial.println(mJob.merkle_branch.size()); + Serial.print(" version: "); Serial.println(mJob.version); + Serial.print(" nbits: "); Serial.println(mJob.nbits); + Serial.print(" ntime: "); Serial.println(mJob.ntime); + Serial.print(" clean_jobs: "); Serial.println(mJob.clean_jobs); #endif //Check if parameters where correctly received if (checkError(doc)) { @@ -229,10 +229,6 @@ bool parse_mining_set_difficulty(String line, double& difficulty) 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); - #endif - return true; } diff --git a/src/utils.cpp b/src/utils.cpp index f7e95ab..1291bdd 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -201,7 +201,7 @@ miner_data calculateMiningData(mining_subscribe& mWorker, mining_job mJob){ size_t res = to_byte_array(coinbase.c_str(), str_len*2, bytearray); #ifdef DEBUG_MINING - Serial.print(" extranonce2: "); Serial.println(extranonce2); + Serial.print(" extranonce2: "); Serial.println(mWorker.extranonce2); Serial.print(" coinbase: "); Serial.println(coinbase); Serial.print(" coinbase bytes - size: "); Serial.println(res); for (size_t i = 0; i < res; i++) @@ -271,7 +271,7 @@ miner_data calculateMiningData(mining_subscribe& mWorker, mining_job mJob){ #ifdef DEBUG_MINING Serial.print(" merkle sha : "); for (size_t i = 0; i < 32; i++) - Serial.printf("%02x", merkle_result[i]); + Serial.printf("%02x", mMiner.merkle_result[i]); Serial.println(""); #endif } @@ -330,35 +330,35 @@ miner_data calculateMiningData(mining_subscribe& mWorker, mining_job mJob){ #ifdef DEBUG_MINING Serial.print(" >>> bytearray_blockheader : "); for (size_t i = 0; i < 4; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.print("version "); for (size_t i = 0; i < 4; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.print("prev hash "); for (size_t i = 4; i < 4+32; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.print("merkle root "); for (size_t i = 36; i < 36+32; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.print("nbits "); for (size_t i = 68; i < 68+4; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.print("difficulty "); for (size_t i = 72; i < 72+4; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.print("nonce "); for (size_t i = 76; i < 76+4; i++) - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); Serial.println(""); Serial.println("bytearray_blockheader: "); for (size_t i = 0; i < str_len; i++) { - Serial.printf("%02x", bytearray_blockheader[i]); + Serial.printf("%02x", mMiner.bytearray_blockheader[i]); } Serial.println(""); #endif