mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-08 19:59:30 +00:00
Use chrono::steady_clock for internal timestamps
This commit is contained in:
parent
796850d8c5
commit
aada1bb5cc
17 changed files with 71 additions and 66 deletions
|
@ -194,8 +194,6 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
|||
m_difficulty = data.difficulty;
|
||||
m_seedHash = data.seed_hash;
|
||||
|
||||
const time_t cur_time = time(nullptr);
|
||||
|
||||
// Only choose transactions that were received 10 or more seconds ago
|
||||
size_t total_mempool_transactions;
|
||||
{
|
||||
|
@ -205,6 +203,8 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
|||
|
||||
total_mempool_transactions = mempool.m_transactions.size();
|
||||
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
for (auto& it : mempool.m_transactions) {
|
||||
if (cur_time >= it.second.time_received + 10) {
|
||||
m_mempoolTxs.emplace_back(it.second);
|
||||
|
@ -252,7 +252,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
|
|||
m_poolBlockTemplate->m_minorVersion = HARDFORK_SUPPORTED_VERSION;
|
||||
|
||||
// Timestamp
|
||||
m_timestamp = cur_time;
|
||||
m_timestamp = time(nullptr);
|
||||
if (m_timestamp <= data.median_timestamp) {
|
||||
LOGWARN(2, "timestamp adjusted from " << m_timestamp << " to " << data.median_timestamp + 1 << ". Fix your system time!");
|
||||
m_timestamp = data.median_timestamp + 1;
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
void update_tx_keys();
|
||||
|
||||
FORCEINLINE uint64_t height() const { return m_height; }
|
||||
FORCEINLINE time_t timestamp() const { return m_timestamp; }
|
||||
FORCEINLINE uint64_t timestamp() const { return m_timestamp; }
|
||||
FORCEINLINE difficulty_type difficulty() const { return m_difficulty; }
|
||||
|
||||
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||
|
|
|
@ -235,7 +235,7 @@ struct TxMempoolData
|
|||
uint64_t blob_size;
|
||||
uint64_t weight;
|
||||
uint64_t fee;
|
||||
time_t time_received;
|
||||
uint64_t time_received;
|
||||
};
|
||||
|
||||
struct MinerData
|
||||
|
|
|
@ -44,7 +44,7 @@ void Mempool::add(const TxMempoolData& tx)
|
|||
|
||||
void Mempool::swap(std::vector<TxMempoolData>& transactions)
|
||||
{
|
||||
const time_t cur_time = time(nullptr);
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
WriteLock lock(m_lock);
|
||||
|
||||
|
|
|
@ -177,8 +177,8 @@ void P2PServer::on_connect_failed(bool is_v6, const raw_ip& ip, int port)
|
|||
|
||||
void P2PServer::update_peer_connections()
|
||||
{
|
||||
const time_t cur_time = time(nullptr);
|
||||
const time_t last_updated = m_pool->side_chain().last_updated();
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
const uint64_t last_updated = m_pool->side_chain().last_updated();
|
||||
|
||||
bool has_good_peers = false;
|
||||
|
||||
|
@ -203,7 +203,7 @@ void P2PServer::update_peer_connections()
|
|||
// - It's been at least 10 seconds since the last block request (peer is not syncing)
|
||||
// - Peer should have sent a broadcast by now
|
||||
if (last_updated && (cur_time >= std::max(last_updated, client->m_lastBlockrequestTimestamp) + 10) && (last_updated >= client->m_lastBroadcastTimestamp + 300)) {
|
||||
const time_t dt = last_updated - client->m_lastBroadcastTimestamp;
|
||||
const uint64_t dt = last_updated - client->m_lastBroadcastTimestamp;
|
||||
LOGWARN(5, "peer " << static_cast<char*>(client->m_addrString) << " is not broadcasting blocks (last update " << dt << " seconds ago)");
|
||||
client->ban(DEFAULT_BAN_TIME);
|
||||
remove_peer_from_list(client);
|
||||
|
@ -316,7 +316,7 @@ void P2PServer::update_peer_list()
|
|||
|
||||
void P2PServer::save_peer_list_async()
|
||||
{
|
||||
const time_t cur_time = time(nullptr);
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
if (cur_time < m_peerListLastSaved + 300) {
|
||||
return;
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ void P2PServer::save_peer_list()
|
|||
f.close();
|
||||
|
||||
LOGINFO(5, "peer list saved (" << peer_list.size() << " peers)");
|
||||
m_peerListLastSaved = time(nullptr);
|
||||
m_peerListLastSaved = seconds_since_epoch();
|
||||
}
|
||||
|
||||
void P2PServer::load_peer_list()
|
||||
|
@ -513,7 +513,7 @@ void P2PServer::load_peer_list()
|
|||
|
||||
p.m_port = port;
|
||||
p.m_numFailedConnections = 0;
|
||||
p.m_lastSeen = time(nullptr);
|
||||
p.m_lastSeen = seconds_since_epoch();
|
||||
|
||||
if (!already_added && !is_banned(p.m_addr)) {
|
||||
m_peerList.push_back(p);
|
||||
|
@ -620,7 +620,7 @@ void P2PServer::load_monerod_peer_list()
|
|||
|
||||
void P2PServer::update_peer_in_list(bool is_v6, const raw_ip& ip, int port)
|
||||
{
|
||||
const time_t cur_time = time(nullptr);
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
MutexLock lock(m_peerListLock);
|
||||
|
||||
|
@ -817,7 +817,7 @@ uint64_t P2PServer::get_random64()
|
|||
|
||||
void P2PServer::print_status()
|
||||
{
|
||||
const int64_t uptime = time(nullptr) - m_pool->start_time();
|
||||
const int64_t uptime = seconds_since_epoch() - m_pool->start_time();
|
||||
|
||||
const int64_t s = uptime % 60;
|
||||
const int64_t m = (uptime / 60) % 60;
|
||||
|
@ -975,8 +975,8 @@ void P2PServer::check_zmq()
|
|||
return;
|
||||
}
|
||||
|
||||
const time_t cur_time = time(nullptr);
|
||||
const time_t last_active = m_pool->zmq_last_active();
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
const uint64_t last_active = m_pool->zmq_last_active();
|
||||
|
||||
if (cur_time >= last_active + 300) {
|
||||
const uint64_t dt = static_cast<uint64_t>(cur_time - last_active);
|
||||
|
@ -993,7 +993,7 @@ P2PServer::P2PClient::P2PClient()
|
|||
, m_handshakeInvalid(false)
|
||||
, m_listenPort(-1)
|
||||
, m_fastPeerListRequestCount(0)
|
||||
, m_prevIncomingPeerListRequest{}
|
||||
, m_prevIncomingPeerListRequest(0)
|
||||
, m_nextOutgoingPeerListRequest(0)
|
||||
, m_lastPeerListRequestTime{}
|
||||
, m_peerListPendingRequests(0)
|
||||
|
@ -1022,7 +1022,7 @@ void P2PServer::P2PClient::reset()
|
|||
m_handshakeInvalid = false;
|
||||
m_listenPort = -1;
|
||||
m_fastPeerListRequestCount = 0;
|
||||
m_prevIncomingPeerListRequest = {};
|
||||
m_prevIncomingPeerListRequest = 0;
|
||||
m_nextOutgoingPeerListRequest = 0;
|
||||
m_lastPeerListRequestTime = {};
|
||||
m_peerListPendingRequests = 0;
|
||||
|
@ -1060,7 +1060,7 @@ bool P2PServer::P2PClient::on_connect()
|
|||
}
|
||||
}
|
||||
|
||||
m_lastAlive = time(nullptr);
|
||||
m_lastAlive = seconds_since_epoch();
|
||||
return send_handshake_challenge();
|
||||
}
|
||||
|
||||
|
@ -1276,7 +1276,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
|
|||
if (bytes_read) {
|
||||
buf += bytes_read;
|
||||
bytes_left -= bytes_read;
|
||||
m_lastAlive = time(nullptr);
|
||||
m_lastAlive = seconds_since_epoch();
|
||||
}
|
||||
} while (bytes_read && bytes_left);
|
||||
|
||||
|
@ -1611,7 +1611,7 @@ void P2PServer::P2PClient::on_after_handshake(uint8_t* &p)
|
|||
p += HASH_SIZE;
|
||||
|
||||
++m_blockPendingRequests;
|
||||
m_lastBroadcastTimestamp = time(nullptr);
|
||||
m_lastBroadcastTimestamp = seconds_since_epoch();
|
||||
}
|
||||
|
||||
bool P2PServer::P2PClient::on_listen_port(const uint8_t* buf)
|
||||
|
@ -1632,7 +1632,7 @@ bool P2PServer::P2PClient::on_listen_port(const uint8_t* buf)
|
|||
|
||||
bool P2PServer::P2PClient::on_block_request(const uint8_t* buf)
|
||||
{
|
||||
m_lastBlockrequestTimestamp = time(nullptr);
|
||||
m_lastBlockrequestTimestamp = seconds_since_epoch();
|
||||
|
||||
hash id;
|
||||
memcpy(id.h, buf, HASH_SIZE);
|
||||
|
@ -1738,20 +1738,18 @@ bool P2PServer::P2PClient::on_block_broadcast(const uint8_t* buf, uint32_t size)
|
|||
|
||||
server->m_block->m_wantBroadcast = true;
|
||||
|
||||
m_lastBroadcastTimestamp = time(nullptr);
|
||||
m_lastBroadcastTimestamp = seconds_since_epoch();
|
||||
|
||||
return handle_incoming_block_async(server->m_block);
|
||||
}
|
||||
|
||||
bool P2PServer::P2PClient::on_peer_list_request(const uint8_t*)
|
||||
{
|
||||
using namespace std::chrono;
|
||||
|
||||
P2PServer* server = static_cast<P2PServer*>(m_owner);
|
||||
const auto cur_time = steady_clock::now();
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
// Allow peer list requests no more than once every 30 seconds
|
||||
if (duration_cast<seconds>(cur_time - m_prevIncomingPeerListRequest).count() < 30) {
|
||||
if (cur_time - m_prevIncomingPeerListRequest < 30) {
|
||||
++m_fastPeerListRequestCount;
|
||||
if (m_fastPeerListRequestCount >= 3) {
|
||||
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " is sending PEER_LIST_REQUEST too often");
|
||||
|
@ -1822,7 +1820,7 @@ bool P2PServer::P2PClient::on_peer_list_request(const uint8_t*)
|
|||
bool P2PServer::P2PClient::on_peer_list_response(const uint8_t* buf) const
|
||||
{
|
||||
P2PServer* server = static_cast<P2PServer*>(m_owner);
|
||||
const time_t cur_time = time(nullptr);
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
MutexLock lock(server->m_peerListLock);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ public:
|
|||
int m_listenPort;
|
||||
|
||||
uint32_t m_fastPeerListRequestCount;
|
||||
std::chrono::steady_clock::time_point m_prevIncomingPeerListRequest;
|
||||
uint64_t m_prevIncomingPeerListRequest;
|
||||
uint64_t m_nextOutgoingPeerListRequest;
|
||||
std::chrono::high_resolution_clock::time_point m_lastPeerListRequestTime;
|
||||
int m_peerListPendingRequests;
|
||||
|
@ -118,9 +118,9 @@ public:
|
|||
|
||||
int m_blockPendingRequests;
|
||||
|
||||
time_t m_lastAlive;
|
||||
time_t m_lastBroadcastTimestamp;
|
||||
time_t m_lastBlockrequestTimestamp;
|
||||
uint64_t m_lastAlive;
|
||||
uint64_t m_lastBroadcastTimestamp;
|
||||
uint64_t m_lastBlockrequestTimestamp;
|
||||
|
||||
hash m_broadcastedHashes[8];
|
||||
std::atomic<uint32_t> m_broadcastedHashesIndex{ 0 };
|
||||
|
@ -188,12 +188,12 @@ private:
|
|||
raw_ip m_addr;
|
||||
int m_port;
|
||||
uint32_t m_numFailedConnections;
|
||||
time_t m_lastSeen;
|
||||
uint64_t m_lastSeen;
|
||||
};
|
||||
|
||||
std::vector<Peer> m_peerList;
|
||||
std::vector<Peer> m_peerListMonero;
|
||||
time_t m_peerListLastSaved;
|
||||
uint64_t m_peerListLastSaved;
|
||||
|
||||
struct Broadcast
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ p2pool::p2pool(int argc, char* argv[])
|
|||
, m_updateSeed(true)
|
||||
, m_submitBlockData{}
|
||||
, m_zmqLastActive(0)
|
||||
, m_startTime(time(nullptr))
|
||||
, m_startTime(seconds_since_epoch())
|
||||
{
|
||||
LOGINFO(1, log::LightCyan() << VERSION);
|
||||
|
||||
|
@ -206,7 +206,7 @@ void p2pool::handle_tx(TxMempoolData& tx)
|
|||
m_blockTemplate->update(m_minerData, *m_mempool, &m_params->m_wallet);
|
||||
#endif
|
||||
|
||||
m_zmqLastActive = time(nullptr);
|
||||
m_zmqLastActive = seconds_since_epoch();
|
||||
}
|
||||
|
||||
void p2pool::handle_miner_data(MinerData& data)
|
||||
|
@ -263,7 +263,7 @@ void p2pool::handle_miner_data(MinerData& data)
|
|||
update_block_template();
|
||||
}
|
||||
|
||||
m_zmqLastActive = time(nullptr);
|
||||
m_zmqLastActive = seconds_since_epoch();
|
||||
|
||||
if (m_serversStarted.load()) {
|
||||
std::vector<uint64_t> missing_heights;
|
||||
|
@ -367,7 +367,7 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
|
|||
|
||||
api_update_network_stats();
|
||||
|
||||
m_zmqLastActive = time(nullptr);
|
||||
m_zmqLastActive = seconds_since_epoch();
|
||||
}
|
||||
|
||||
void p2pool::submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
|
||||
|
|
|
@ -87,8 +87,8 @@ public:
|
|||
void stop_mining();
|
||||
#endif
|
||||
|
||||
time_t zmq_last_active() const { return m_zmqLastActive; }
|
||||
time_t start_time() const { return m_startTime; }
|
||||
uint64_t zmq_last_active() const { return m_zmqLastActive; }
|
||||
uint64_t start_time() const { return m_startTime; }
|
||||
|
||||
private:
|
||||
p2pool(const p2pool&) = delete;
|
||||
|
@ -185,8 +185,8 @@ private:
|
|||
uv_async_t m_blockTemplateAsync;
|
||||
uv_async_t m_stopAsync;
|
||||
|
||||
time_t m_zmqLastActive;
|
||||
time_t m_startTime;
|
||||
uint64_t m_zmqLastActive;
|
||||
uint64_t m_startTime;
|
||||
|
||||
ZMQReader* m_ZMQReader = nullptr;
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ PoolBlock::PoolBlock()
|
|||
, m_invalid(false)
|
||||
, m_broadcasted(false)
|
||||
, m_wantBroadcast(false)
|
||||
, m_localTimestamp(time(nullptr))
|
||||
, m_localTimestamp(seconds_since_epoch())
|
||||
{
|
||||
uv_mutex_init_checked(&m_lock);
|
||||
|
||||
|
@ -115,7 +115,7 @@ PoolBlock& PoolBlock::operator=(const PoolBlock& b)
|
|||
m_broadcasted = b.m_broadcasted;
|
||||
m_wantBroadcast = b.m_wantBroadcast;
|
||||
|
||||
m_localTimestamp = time(nullptr);
|
||||
m_localTimestamp = seconds_since_epoch();
|
||||
|
||||
if (lock_result == 0) {
|
||||
uv_mutex_unlock(&b.m_lock);
|
||||
|
|
|
@ -130,7 +130,7 @@ struct PoolBlock
|
|||
bool m_broadcasted;
|
||||
bool m_wantBroadcast;
|
||||
|
||||
time_t m_localTimestamp;
|
||||
uint64_t m_localTimestamp;
|
||||
|
||||
void serialize_mainchain_data(uint32_t nonce, uint32_t extra_nonce, const hash& sidechain_hash);
|
||||
void serialize_sidechain_data();
|
||||
|
|
|
@ -350,7 +350,7 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, SideChain& sidechai
|
|||
m_broadcasted = false;
|
||||
m_wantBroadcast = false;
|
||||
|
||||
m_localTimestamp = time(nullptr);
|
||||
m_localTimestamp = seconds_since_epoch();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -781,7 +781,7 @@ difficulty_type SideChain::total_hashes() const
|
|||
|
||||
uint64_t SideChain::miner_count()
|
||||
{
|
||||
const time_t cur_time = time(nullptr);
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
|
||||
MutexLock lock(m_sidechainLock);
|
||||
|
||||
|
@ -798,7 +798,7 @@ uint64_t SideChain::miner_count()
|
|||
return m_seenWallets.size();
|
||||
}
|
||||
|
||||
time_t SideChain::last_updated() const
|
||||
uint64_t SideChain::last_updated() const
|
||||
{
|
||||
return m_chainTip ? m_chainTip->m_localTimestamp : 0;
|
||||
}
|
||||
|
@ -1584,7 +1584,8 @@ void SideChain::prune_old_blocks()
|
|||
const uint64_t prune_distance = m_chainWindowSize * 2 + 120 / m_targetBlockTime;
|
||||
|
||||
// Remove old blocks from alternative unconnected chains after long enough time
|
||||
const time_t prune_time = time(nullptr) - m_chainWindowSize * 4 * m_targetBlockTime;
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
const uint64_t prune_delay = m_chainWindowSize * 4 * m_targetBlockTime;
|
||||
|
||||
if (m_chainTip->m_sidechainHeight < prune_distance) {
|
||||
return;
|
||||
|
@ -1599,9 +1600,9 @@ void SideChain::prune_old_blocks()
|
|||
std::vector<PoolBlock*>& v = it->second;
|
||||
|
||||
v.erase(std::remove_if(v.begin(), v.end(),
|
||||
[this, prune_distance, prune_time, &num_blocks_pruned, height](PoolBlock* block)
|
||||
[this, prune_distance, cur_time, prune_delay, &num_blocks_pruned, height](PoolBlock* block)
|
||||
{
|
||||
if ((block->m_depth >= prune_distance) || (block->m_localTimestamp <= prune_time)) {
|
||||
if ((block->m_depth >= prune_distance) || (cur_time >= block->m_localTimestamp + prune_delay)) {
|
||||
auto it2 = m_blocksById.find(block->m_sidechainId);
|
||||
if (it2 != m_blocksById.end()) {
|
||||
m_blocksById.erase(it2);
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
difficulty_type total_hashes() const;
|
||||
uint64_t block_time() const { return m_targetBlockTime; }
|
||||
uint64_t miner_count();
|
||||
time_t last_updated() const;
|
||||
uint64_t last_updated() const;
|
||||
bool is_default() const;
|
||||
bool is_mini() const;
|
||||
|
||||
|
@ -102,7 +102,7 @@ private:
|
|||
PoolBlock* m_chainTip;
|
||||
std::map<uint64_t, std::vector<PoolBlock*>> m_blocksByHeight;
|
||||
unordered_map<hash, PoolBlock*> m_blocksById;
|
||||
unordered_map<hash, time_t> m_seenWallets;
|
||||
unordered_map<hash, uint64_t> m_seenWallets;
|
||||
std::vector<MinerShare> m_tmpShares;
|
||||
std::vector<uint64_t> m_tmpRewards;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ StratumServer::StratumServer(p2pool* pool)
|
|||
// Diffuse the initial state in case it has low quality
|
||||
m_rng.discard(10000);
|
||||
|
||||
m_hashrateData[0] = { time(nullptr), 0 };
|
||||
m_hashrateData[0] = { seconds_since_epoch(), 0 };
|
||||
|
||||
uv_mutex_init_checked(&m_blobsQueueLock);
|
||||
uv_mutex_init_checked(&m_rngLock);
|
||||
|
@ -437,7 +437,7 @@ uint64_t StratumServer::get_random64()
|
|||
|
||||
void StratumServer::print_status()
|
||||
{
|
||||
update_hashrate_data(0, time(nullptr));
|
||||
update_hashrate_data(0, seconds_since_epoch());
|
||||
print_stratum_status();
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ void StratumServer::on_blobs_ready()
|
|||
size_t numClientsProcessed = 0;
|
||||
uint32_t extra_nonce = 0;
|
||||
|
||||
const time_t cur_time = time(nullptr);
|
||||
const uint64_t cur_time = seconds_since_epoch();
|
||||
{
|
||||
MutexLock lock2(m_clientsListLock);
|
||||
|
||||
|
@ -605,7 +605,7 @@ void StratumServer::on_blobs_ready()
|
|||
LOGINFO(3, "sent new job to " << extra_nonce << '/' << numClientsProcessed << " clients");
|
||||
}
|
||||
|
||||
void StratumServer::update_hashrate_data(uint64_t hashes, time_t timestamp)
|
||||
void StratumServer::update_hashrate_data(uint64_t hashes, uint64_t timestamp)
|
||||
{
|
||||
constexpr size_t N = array_size(&StratumServer::m_hashrateData);
|
||||
|
||||
|
@ -707,7 +707,7 @@ void StratumServer::on_share_found(uv_work_t* req)
|
|||
const uint64_t value = *reinterpret_cast<uint64_t*>(share->m_resultHash.h + HASH_SIZE - sizeof(uint64_t));
|
||||
|
||||
if (LIKELY(value < target)) {
|
||||
const time_t timestamp = time(nullptr);
|
||||
const uint64_t timestamp = seconds_since_epoch();
|
||||
server->update_hashrate_data(hashes, timestamp);
|
||||
server->api_update_local_stats(timestamp);
|
||||
share->m_result = SubmittedShare::Result::OK;
|
||||
|
@ -803,7 +803,7 @@ void StratumServer::StratumClient::reset()
|
|||
|
||||
bool StratumServer::StratumClient::on_connect()
|
||||
{
|
||||
m_connectedTime = time(nullptr);
|
||||
m_connectedTime = seconds_since_epoch();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -993,7 +993,7 @@ bool StratumServer::StratumClient::process_submit(rapidjson::Document& doc, uint
|
|||
return static_cast<StratumServer*>(m_owner)->on_submit(this, id, job_id.GetString(), nonce.GetString(), result.GetString());
|
||||
}
|
||||
|
||||
void StratumServer::api_update_local_stats(time_t timestamp)
|
||||
void StratumServer::api_update_local_stats(uint64_t timestamp)
|
||||
{
|
||||
if (!m_pool->api() || !m_pool->params().m_localStats) {
|
||||
return;
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
bool process_submit(rapidjson::Document& doc, uint32_t id);
|
||||
|
||||
uint32_t m_rpcId;
|
||||
time_t m_connectedTime;
|
||||
uint64_t m_connectedTime;
|
||||
|
||||
uv_mutex_t m_jobsLock;
|
||||
|
||||
|
@ -140,7 +140,7 @@ private:
|
|||
|
||||
struct HashrateData
|
||||
{
|
||||
time_t m_timestamp;
|
||||
uint64_t m_timestamp;
|
||||
uint64_t m_cumulativeHashes;
|
||||
};
|
||||
|
||||
|
@ -157,10 +157,10 @@ private:
|
|||
double m_cumulativeFoundSharesDiff;
|
||||
uint32_t m_totalFoundShares;
|
||||
|
||||
time_t m_apiLastUpdateTime;
|
||||
uint64_t m_apiLastUpdateTime;
|
||||
|
||||
void update_hashrate_data(uint64_t hashes, time_t timestamp);
|
||||
void api_update_local_stats(time_t timestamp);
|
||||
void update_hashrate_data(uint64_t hashes, uint64_t timestamp);
|
||||
void api_update_local_stats(uint64_t timestamp);
|
||||
};
|
||||
|
||||
} // namespace p2pool
|
||||
|
|
|
@ -163,6 +163,12 @@ struct RandomDeviceSeed
|
|||
static RandomDeviceSeed instance;
|
||||
};
|
||||
|
||||
FORCEINLINE uint64_t seconds_since_epoch()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
return duration_cast<seconds>(steady_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
namespace robin_hood {
|
||||
|
|
|
@ -207,7 +207,7 @@ void ZMQReader::parse(char* data, size_t size)
|
|||
return;
|
||||
}
|
||||
|
||||
m_tx.time_received = time(nullptr);
|
||||
m_tx.time_received = seconds_since_epoch();
|
||||
|
||||
for (SizeType i = 0, n = doc.Size(); i < n; ++i) {
|
||||
const auto& v = doc[i];
|
||||
|
|
Loading…
Reference in a new issue