@ -1334,11 +1334,12 @@ bool Blockchain::complete_timestamps_vector(uint64_t start_top_height, std::vect
{
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
if ( timestamps . size ( ) > = BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW )
uint64_t blockchain_timestamp_check_window = get_current_hard_fork_version ( ) < 9 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 ;
if ( timestamps . size ( ) > = blockchain_timestamp_check_window )
return true ;
CRITICAL_REGION_LOCAL ( m_blockchain_lock ) ;
size_t need_elements = BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW - timestamps . size ( ) ;
size_t need_elements = blockchain_timestamp_check_window - timestamps . size ( ) ;
CHECK_AND_ASSERT_MES ( start_top_height < m_db - > height ( ) , false , " internal error: passed start_height not < " < < " m_db->height() -- " < < start_top_height < < " >= " < < m_db - > height ( ) ) ;
size_t stop_offset = start_top_height > need_elements ? start_top_height - need_elements : 0 ;
while ( start_top_height ! = stop_offset )
@ -3195,9 +3196,10 @@ bool Blockchain::check_block_timestamp(std::vector<uint64_t>& timestamps, const
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
uint64_t median_ts = epee : : misc_utils : : median ( timestamps ) ;
uint64_t blockchain_timestamp_check_window = get_current_hard_fork_version ( ) < 9 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 ;
if ( b . timestamp < median_ts )
{
MERROR_VER ( " Timestamp of block with id: " < < get_block_hash ( b ) < < " , " < < b . timestamp < < " , less than median of last " < < BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW < < " blocks, " < < median_ts ) ;
MERROR_VER ( " Timestamp of block with id: " < < get_block_hash ( b ) < < " , " < < b . timestamp < < " , less than median of last " < < blockchain_timestamp_check_window < < " blocks, " < < median_ts ) ;
return false ;
}
@ -3214,15 +3216,16 @@ bool Blockchain::check_block_timestamp(std::vector<uint64_t>& timestamps, const
bool Blockchain : : check_block_timestamp ( const block & b ) const
{
LOG_PRINT_L3 ( " Blockchain:: " < < __func__ ) ;
uint64_t cryptonote_block_future_time_limit = get_current_hard_fork_version ( ) < 7 ? CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT : CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2 ;
uint64_t cryptonote_block_future_time_limit = get_current_hard_fork_version ( ) < 9 ? CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2 : CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V3 ;
uint64_t blockchain_timestamp_check_window = get_current_hard_fork_version ( ) < 9 ? BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW : BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V2 ;
if ( b . timestamp > get_adjusted_time ( ) + cryptonote_block_future_time_limit )
{
MERROR_VER ( " Timestamp of block with id: " < < get_block_hash ( b ) < < " , " < < b . timestamp < < " , bigger than adjusted time + 2 hour s" ) ;
MERROR_VER ( " Timestamp of block with id: " < < get_block_hash ( b ) < < " , " < < b . timestamp < < " , bigger than adjusted time + 7 minute s" ) ;
return false ;
}
// if not enough blocks, no proper median yet, return true
if ( m_db - > height ( ) < BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW )
if ( m_db - > height ( ) < blockchain_timestamp_check_window )
{
return true ;
}
@ -3231,7 +3234,7 @@ bool Blockchain::check_block_timestamp(const block& b) const
auto h = m_db - > height ( ) ;
// need most recent 60 blocks, get index of first of those
size_t offset = h - BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW ;
size_t offset = h - blockchain_timestamp_check_window ;
for ( ; offset < h ; + + offset )
{
timestamps . push_back ( m_db - > get_block_timestamp ( offset ) ) ;