From 41effdc6e879c8f0546173e21a109003321d3b44 Mon Sep 17 00:00:00 2001 From: shengguang Date: Tue, 11 Jun 2019 15:39:43 +0800 Subject: [PATCH] Move retry send pow time to constants.xml --- constants.xml | 1 + constants_local.xml | 1 + src/common/Constants.cpp | 2 ++ src/common/Constants.h | 1 + src/libPOW/pow.cpp | 5 ++--- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/constants.xml b/constants.xml index a6e8135005..d2b591004d 100644 --- a/constants.xml +++ b/constants.xml @@ -177,6 +177,7 @@ false false http://127.0.0.1:4202/api + 5 5 diff --git a/constants_local.xml b/constants_local.xml index 0176aa4b7a..fef2d0b9c6 100644 --- a/constants_local.xml +++ b/constants_local.xml @@ -176,6 +176,7 @@ false false http://127.0.0.1:4202/api + 5 5 diff --git a/src/common/Constants.cpp b/src/common/Constants.cpp index f4778c3e82..8032387370 100644 --- a/src/common/Constants.cpp +++ b/src/common/Constants.cpp @@ -352,6 +352,8 @@ const bool REMOTE_MINE{ReadConstantString("REMOTE_MINE", "node.pow.") == "true"}; const std::string MINING_PROXY_URL{ ReadConstantString("MINING_PROXY_URL", "node.pow.")}; +const unsigned int MAX_RETRY_SEND_POW_TIME{ + ReadConstantNumeric("MAX_RETRY_SEND_POW_TIME", "node.pow.")}; const unsigned int CHECK_MINING_RESULT_INTERVAL{ ReadConstantNumeric("CHECK_MINING_RESULT_INTERVAL", "node.pow.")}; const bool GETWORK_SERVER_MINE{ diff --git a/src/common/Constants.h b/src/common/Constants.h index c13329b288..09b8e3a9ab 100644 --- a/src/common/Constants.h +++ b/src/common/Constants.h @@ -287,6 +287,7 @@ extern const bool FULL_DATASET_MINE; extern const bool OPENCL_GPU_MINE; extern const bool REMOTE_MINE; extern const std::string MINING_PROXY_URL; +extern const unsigned int MAX_RETRY_SEND_POW_TIME; extern const unsigned int CHECK_MINING_RESULT_INTERVAL; extern const bool GETWORK_SERVER_MINE; extern const unsigned int GETWORK_SERVER_PORT; diff --git a/src/libPOW/pow.cpp b/src/libPOW/pow.cpp index 582a647bfc..5eb69e2eb8 100644 --- a/src/libPOW/pow.cpp +++ b/src/libPOW/pow.cpp @@ -387,8 +387,7 @@ ethash_mining_result_t POW::RemoteMine(const PairOfKey& pairOfKey, m_shouldMine = true; ethash_mining_result_t miningResult{"", "", 0, false}; - const int MAX_RETRY_SEND_TIME = 5; - int retryTime = 0; + uint32_t retryTime = 0; bool sendWorkSuccess = false; do { if (SendWorkToProxy(pairOfKey, blockNum, headerHash, boundary, @@ -398,7 +397,7 @@ ethash_mining_result_t POW::RemoteMine(const PairOfKey& pairOfKey, } ++retryTime; std::this_thread::sleep_for(std::chrono::seconds(1)); - } while (!sendWorkSuccess && retryTime <= MAX_RETRY_SEND_TIME); + } while (!sendWorkSuccess && retryTime <= MAX_RETRY_SEND_POW_TIME); if (!sendWorkSuccess) { LOG_GENERAL(WARNING, "Failed to send work package to mining proxy.");