Skip to content

Commit

Permalink
Move retry send pow time to constants.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
ShengguangXiao committed Jun 11, 2019
1 parent d4dc67d commit 41effdc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions constants.xml
Expand Up @@ -177,6 +177,7 @@
<OPENCL_GPU_MINE>false</OPENCL_GPU_MINE>
<REMOTE_MINE>false</REMOTE_MINE>
<MINING_PROXY_URL>http://127.0.0.1:4202/api</MINING_PROXY_URL>
<MAX_RETRY_SEND_POW_TIME>5</MAX_RETRY_SEND_POW_TIME>
<!-- Every interval seconds to check if mining proxy has the PoW result -->
<CHECK_MINING_RESULT_INTERVAL>5</CHECK_MINING_RESULT_INTERVAL>
<!-- Make zilliqa node as an getWork server -->
Expand Down
1 change: 1 addition & 0 deletions constants_local.xml
Expand Up @@ -176,6 +176,7 @@
<OPENCL_GPU_MINE>false</OPENCL_GPU_MINE>
<REMOTE_MINE>false</REMOTE_MINE>
<MINING_PROXY_URL>http://127.0.0.1:4202/api</MINING_PROXY_URL>
<MAX_RETRY_SEND_POW_TIME>5</MAX_RETRY_SEND_POW_TIME>
<!-- Every interval seconds to check if mining proxy has the PoW result -->
<CHECK_MINING_RESULT_INTERVAL>5</CHECK_MINING_RESULT_INTERVAL>
<!-- Make zilliqa node as an getWork server -->
Expand Down
2 changes: 2 additions & 0 deletions src/common/Constants.cpp
Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions src/common/Constants.h
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/libPOW/pow.cpp
Expand Up @@ -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,
Expand All @@ -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.");
Expand Down

0 comments on commit 41effdc

Please sign in to comment.