Use chrono::steady_clock for internal timestamps

This commit is contained in:
SChernykh
2022-03-23 11:30:38 +01:00
parent 796850d8c5
commit aada1bb5cc
17 changed files with 71 additions and 66 deletions

View File

@@ -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;