diff options
author | Javier Smooth <iamjaviersmooth@gmail.com> | 2015-11-13 00:24:47 -0800 |
---|---|---|
committer | Javier Smooth <iamjaviersmooth@gmail.com> | 2015-11-13 00:37:35 -0800 |
commit | baf101ef4a05ae4d24ed717c16be929456775969 (patch) | |
tree | 807afcbc2d1faf2f792a774d72a62ee835934092 /src/cryptonote_core | |
parent | Adjust difficulty target (2 min) and full reward zone (60 kbytes) for block v... (diff) | |
download | monero-baf101ef4a05ae4d24ed717c16be929456775969.tar.xz |
More changes for 2-min blocks
Use the correct block time for realtime fuzz on locktime
Use the correct block time to calculate next_difficulty on alt chains (will not work as-is with voting)
Lock unit tests to original block time for now
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 11 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain_storage.cpp | 6 | ||||
-rw-r--r-- | src/cryptonote_core/difficulty.cpp | 4 | ||||
-rw-r--r-- | src/cryptonote_core/difficulty.h | 1 |
5 files changed, 12 insertions, 12 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index a24ef8283..e6a233868 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -674,8 +674,8 @@ difficulty_type Blockchain::get_difficulty_for_next_block() m_timestamps = timestamps; m_difficulties = difficulties; } - - return next_difficulty(timestamps, difficulties); + size_t target = get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET; + return next_difficulty(timestamps, difficulties, target); } //------------------------------------------------------------------ // This function removes blocks from the blockchain until it gets to the @@ -865,8 +865,11 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std: } } + // FIXME: This will fail if fork activation heights are subject to voting + size_t target = get_ideal_hard_fork_version(bei.height) < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET; + // calculate the difficulty target for the block and return it - return next_difficulty(timestamps, cumulative_difficulties); + return next_difficulty(timestamps, cumulative_difficulties, target); } //------------------------------------------------------------------ // This function does a sanity check on basic things that all miner @@ -2194,7 +2197,7 @@ bool Blockchain::is_tx_spendtime_unlocked(uint64_t unlock_time) const { //interpret as time uint64_t current_time = static_cast<uint64_t>(time(NULL)); - if(current_time + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS >= unlock_time) + if(current_time + (get_current_hard_fork_version() < 2 ? CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 : CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS) >= unlock_time) return true; else return false; diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 00670c6d3..c83314634 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -160,6 +160,8 @@ namespace cryptonote HardFork::State get_hard_fork_state() const; uint8_t get_current_hard_fork_version() const { return m_hardfork->get_current_version(); } uint8_t get_ideal_hard_fork_version() const { return m_hardfork->get_ideal_version(); } + uint8_t get_ideal_hard_fork_version(uint64_t height) const { return m_hardfork->get_ideal_version(height); } + bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const; bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const; diff --git a/src/cryptonote_core/blockchain_storage.cpp b/src/cryptonote_core/blockchain_storage.cpp index fb06da48a..f7c9ffb78 100644 --- a/src/cryptonote_core/blockchain_storage.cpp +++ b/src/cryptonote_core/blockchain_storage.cpp @@ -430,7 +430,7 @@ difficulty_type blockchain_storage::get_difficulty_for_next_block() const timestamps.push_back(m_blocks[offset].bl.timestamp); commulative_difficulties.push_back(m_blocks[offset].cumulative_difficulty); } - return next_difficulty(timestamps, commulative_difficulties); + return next_difficulty(timestamps, commulative_difficulties,DIFFICULTY_TARGET_V1); } //------------------------------------------------------------------ bool blockchain_storage::rollback_blockchain_switching(std::list<block>& original_chain, size_t rollback_height) @@ -571,7 +571,7 @@ difficulty_type blockchain_storage::get_next_difficulty_for_alternative_chain(co break; } } - return next_difficulty(timestamps, commulative_difficulties); + return next_difficulty(timestamps, commulative_difficulties,DIFFICULTY_TARGET_V1); } //------------------------------------------------------------------ bool blockchain_storage::prevalidate_miner_transaction(const block& b, uint64_t height) const @@ -1505,7 +1505,7 @@ bool blockchain_storage::is_tx_spendtime_unlocked(uint64_t unlock_time) const { //interpret as time uint64_t current_time = static_cast<uint64_t>(time(NULL)); - if(current_time + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS >= unlock_time) + if(current_time + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 >= unlock_time) return true; else return false; diff --git a/src/cryptonote_core/difficulty.cpp b/src/cryptonote_core/difficulty.cpp index 2b5466791..3c3f1dec1 100644 --- a/src/cryptonote_core/difficulty.cpp +++ b/src/cryptonote_core/difficulty.cpp @@ -157,8 +157,4 @@ namespace cryptonote { return (low + time_span - 1) / time_span; } - difficulty_type next_difficulty(vector<uint64_t> timestamps, vector<difficulty_type> cumulative_difficulties) - { - return next_difficulty(std::move(timestamps), std::move(cumulative_difficulties), DIFFICULTY_TARGET); - } } diff --git a/src/cryptonote_core/difficulty.h b/src/cryptonote_core/difficulty.h index 42d2df500..6e06dd702 100644 --- a/src/cryptonote_core/difficulty.h +++ b/src/cryptonote_core/difficulty.h @@ -40,6 +40,5 @@ namespace cryptonote typedef std::uint64_t difficulty_type; bool check_hash(const crypto::hash &hash, difficulty_type difficulty); - difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties); difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds); } |