mirror of
https://github.com/monero-project/monero.git
synced 2025-07-23 05:30:50 -04:00
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
This commit is contained in:
parent
4fea1a5fe7
commit
baf101ef4a
7 changed files with 18 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue