mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-02-02 03:06:27 +00:00
More time handling fixes
This commit is contained in:
parent
ef15c3b54f
commit
0c2b7d6010
5 changed files with 7 additions and 7 deletions
|
@ -261,7 +261,7 @@ struct MinerData
|
||||||
uint64_t median_timestamp;
|
uint64_t median_timestamp;
|
||||||
std::vector<TxMempoolData> tx_backlog;
|
std::vector<TxMempoolData> tx_backlog;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point time_received;
|
std::chrono::high_resolution_clock::time_point time_received;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ChainMain
|
struct ChainMain
|
||||||
|
|
|
@ -51,10 +51,10 @@ private:
|
||||||
std::vector<WorkerData*> m_minerThreads;
|
std::vector<WorkerData*> m_minerThreads;
|
||||||
volatile bool m_stopped;
|
volatile bool m_stopped;
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> m_startTimestamp;
|
std::chrono::high_resolution_clock::time_point m_startTimestamp;
|
||||||
|
|
||||||
std::atomic<uint32_t> m_nonce;
|
std::atomic<uint32_t> m_nonce;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> m_nonceTimestamp;
|
std::chrono::high_resolution_clock::time_point m_nonceTimestamp;
|
||||||
const uint32_t m_extraNonce;
|
const uint32_t m_extraNonce;
|
||||||
|
|
||||||
uint64_t m_totalHashes;
|
uint64_t m_totalHashes;
|
||||||
|
|
|
@ -1713,7 +1713,7 @@ bool P2PServer::P2PClient::on_block_broadcast(const uint8_t* buf, uint32_t size)
|
||||||
if (peer_height < our_height) {
|
if (peer_height < our_height) {
|
||||||
if (our_height - peer_height < 5) {
|
if (our_height - peer_height < 5) {
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
const int64_t elapsed_ms = duration_cast<milliseconds>(system_clock::now() - miner_data.time_received).count();
|
const int64_t elapsed_ms = duration_cast<milliseconds>(high_resolution_clock::now() - miner_data.time_received).count();
|
||||||
if (our_height - peer_height > 1) {
|
if (our_height - peer_height > 1) {
|
||||||
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " broadcasted a stale block (" << elapsed_ms << " ms late, mainchain height " << peer_height << ", expected >= " << our_height << "), ignoring it");
|
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " broadcasted a stale block (" << elapsed_ms << " ms late, mainchain height " << peer_height << ", expected >= " << our_height << "), ignoring it");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -238,7 +238,7 @@ void p2pool::handle_miner_data(MinerData& data)
|
||||||
}
|
}
|
||||||
|
|
||||||
data.tx_backlog.clear();
|
data.tx_backlog.clear();
|
||||||
data.time_received = std::chrono::system_clock::now();
|
data.time_received = std::chrono::high_resolution_clock::now();
|
||||||
m_minerData = data;
|
m_minerData = data;
|
||||||
m_updateSeed = true;
|
m_updateSeed = true;
|
||||||
update_median_timestamp();
|
update_median_timestamp();
|
||||||
|
|
|
@ -159,10 +159,10 @@ bool ZMQReader::connect(const char* address)
|
||||||
m_subscriber.connect(address);
|
m_subscriber.connect(address);
|
||||||
|
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
system_clock::time_point start_time = system_clock::now();
|
steady_clock::time_point start_time = steady_clock::now();
|
||||||
|
|
||||||
while (!monitor.connected && monitor.check_event(-1)) {
|
while (!monitor.connected && monitor.check_event(-1)) {
|
||||||
const system_clock::time_point cur_time = system_clock::now();
|
const steady_clock::time_point cur_time = steady_clock::now();
|
||||||
const int64_t elapsed_time = duration_cast<milliseconds>(cur_time - start_time).count();
|
const int64_t elapsed_time = duration_cast<milliseconds>(cur_time - start_time).count();
|
||||||
if (elapsed_time >= 3000) {
|
if (elapsed_time >= 3000) {
|
||||||
LOGERR(1, "failed to connect to " << address);
|
LOGERR(1, "failed to connect to " << address);
|
||||||
|
|
Loading…
Reference in a new issue