Allow only one pending get_miner_data

This commit is contained in:
SChernykh 2022-05-12 00:18:02 +02:00
parent 516c382fe4
commit 5cea7be405
2 changed files with 9 additions and 1 deletions

View file

@ -911,6 +911,8 @@ void p2pool::parse_get_version_rpc(const char* data, size_t size)
void p2pool::get_miner_data()
{
m_getMinerDataPending = true;
JSONRPCRequest::call(m_params->m_host.c_str(), m_params->m_rpcPort, "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_miner_data\"}",
[this](const char* data, size_t size)
{
@ -923,6 +925,9 @@ void p2pool::get_miner_data()
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
get_miner_data();
}
else {
m_getMinerDataPending = false;
}
});
}
@ -1407,7 +1412,9 @@ void p2pool::restart_zmq()
return;
}
get_miner_data();
if (!m_getMinerDataPending) {
get_miner_data();
}
delete m_ZMQReader;
m_ZMQReader = nullptr;

View file

@ -204,6 +204,7 @@ private:
ZMQReader* m_ZMQReader = nullptr;
hash m_getMinerDataHash;
bool m_getMinerDataPending = false;
};
} // namespace p2pool