aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-09-30 18:52:11 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-09-30 18:52:11 -0500
commit17f063a50fcacea4e124b8dcdee617d37ef61372 (patch)
treeb589a3780e159a24e860e6df0a7407ccce17891e /src/cryptonote_core
parentMerge pull request #5900 (diff)
parentblockchain: keep block template timestamp not below recent median (diff)
downloadmonero-17f063a50fcacea4e124b8dcdee617d37ef61372.tar.xz
Merge pull request #5902
b9da023 blockchain: keep block template timestamp not below recent median (moneromooo-monero)
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index bcf99bbed..de0279b4b 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1315,7 +1315,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;