|
|
@ -1141,6 +1141,12 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
|
|
|
|
b.prev_id = get_tail_id();
|
|
|
|
b.prev_id = get_tail_id();
|
|
|
|
b.timestamp = time(NULL);
|
|
|
|
b.timestamp = time(NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t median_ts;
|
|
|
|
|
|
|
|
if (!check_block_timestamp(b, median_ts))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
b.timestamp = median_ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
diffic = get_difficulty_for_next_block();
|
|
|
|
diffic = get_difficulty_for_next_block();
|
|
|
|
CHECK_AND_ASSERT_MES(diffic, false, "difficulty overhead.");
|
|
|
|
CHECK_AND_ASSERT_MES(diffic, false, "difficulty overhead.");
|
|
|
|
|
|
|
|
|
|
|
@ -3126,10 +3132,10 @@ uint64_t Blockchain::get_adjusted_time() const
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//TODO: revisit, has changed a bit on upstream
|
|
|
|
//TODO: revisit, has changed a bit on upstream
|
|
|
|
bool Blockchain::check_block_timestamp(std::vector<uint64_t>& timestamps, const block& b) const
|
|
|
|
bool Blockchain::check_block_timestamp(std::vector<uint64_t>& timestamps, const block& b, uint64_t& median_ts) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
|
|
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
|
|
|
uint64_t median_ts = epee::misc_utils::median(timestamps);
|
|
|
|
median_ts = epee::misc_utils::median(timestamps);
|
|
|
|
|
|
|
|
|
|
|
|
if(b.timestamp < median_ts)
|
|
|
|
if(b.timestamp < median_ts)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -3147,7 +3153,7 @@ bool Blockchain::check_block_timestamp(std::vector<uint64_t>& timestamps, const
|
|
|
|
// true if the block's timestamp is not less than the timestamp of the
|
|
|
|
// true if the block's timestamp is not less than the timestamp of the
|
|
|
|
// median of the selected blocks
|
|
|
|
// median of the selected blocks
|
|
|
|
// false otherwise
|
|
|
|
// false otherwise
|
|
|
|
bool Blockchain::check_block_timestamp(const block& b) const
|
|
|
|
bool Blockchain::check_block_timestamp(const block& b, uint64_t& median_ts) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
|
|
|
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() < 7 ? CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT : CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2;
|
|
|
@ -3173,7 +3179,7 @@ bool Blockchain::check_block_timestamp(const block& b) const
|
|
|
|
timestamps.push_back(m_db->get_block_timestamp(offset));
|
|
|
|
timestamps.push_back(m_db->get_block_timestamp(offset));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return check_block_timestamp(timestamps, b);
|
|
|
|
return check_block_timestamp(timestamps, b, median_ts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void Blockchain::return_tx_to_pool(std::vector<transaction> &txs)
|
|
|
|
void Blockchain::return_tx_to_pool(std::vector<transaction> &txs)
|
|
|
|