diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-09-10 13:36:09 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-09-11 15:21:52 +0000 |
commit | b9da0234e91cf816bd181ab141242ff8765ad118 (patch) | |
tree | c4478bdecc654790e1c5564c2a552430ea922339 /src/cryptonote_core | |
parent | Merge pull request #5876 (diff) | |
download | monero-b9da0234e91cf816bd181ab141242ff8765ad118.tar.xz |
blockchain: keep block template timestamp not below recent median
Such a template would yield an invalid block, though would require
an attacker to have mined a long blockchain with drifting times
(assuming the miner's clock is roughly correct)
Fixed by crCr62U0
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 8ed0e526a..b04c04ad8 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1385,7 +1385,9 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block, if (!memcmp(&miner_address, &m_btc_address, sizeof(cryptonote::account_public_address)) && m_btc_nonce == ex_nonce && m_btc_pool_cookie == m_tx_pool.cookie() && m_btc.prev_id == get_tail_id()) { MDEBUG("Using cached template"); - m_btc.timestamp = time(NULL); // update timestamp unconditionally + const uint64_t now = time(NULL); + if (m_btc.timestamp < now) // ensures it can't get below the median of the last few blocks + m_btc.timestamp = now; b = m_btc; diffic = m_btc_difficulty; height = m_btc_height; |