Skip to content

Commit

Permalink
Clarify a bit block timestamp errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aivve committed Jan 22, 2022
1 parent 2307f5d commit 1dc84a3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/CryptoNoteCore/Blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ bool Blockchain::init(const std::string& config_folder, bool load_existing) {
<< "Blockchain initialized. last block: " << m_blocks.size() - 1 << ", "
<< Common::timeIntervalToString(timestamp_diff)
<< " time ago, current difficulty: " << getDifficultyForNextBlock(getTailId());

return true;
}

Expand Down Expand Up @@ -2010,8 +2011,10 @@ uint64_t Blockchain::get_adjusted_time() {

bool Blockchain::check_block_timestamp_main(const Block& b) {
if (b.timestamp > get_adjusted_time() + m_currency.blockFutureTimeLimit(b.majorVersion)) {
time_t t = static_cast<time_t>(b.timestamp);
auto tm = *std::localtime(&t);
logger(INFO, BRIGHT_WHITE) <<
"Timestamp of block with id: " << get_block_hash(b) << ", " << b.timestamp << ", bigger than adjusted time + 28 min.";
"Timestamp of block with id: " << get_block_hash(b) << ", " << b.timestamp << " (" << std::put_time(&tm, "%Y-%m-%d %H:%M:%S") << ") is too far in the future";
return false;
}

Expand Down Expand Up @@ -2040,9 +2043,10 @@ bool Blockchain::check_block_timestamp(std::vector<uint64_t> timestamps, const B
uint64_t median_ts = Common::medianValue(timestamps);

if (b.timestamp < median_ts) {
logger(INFO, BRIGHT_WHITE) <<
"Timestamp of block with id: " << get_block_hash(b) << ", " << b.timestamp <<
", less than median of last " << m_currency.timestampCheckWindow(b.majorVersion) << " blocks, " << median_ts;
logger(INFO, BRIGHT_WHITE)
<< "Timestamp of block with id " << get_block_hash(b) << ", " << b.timestamp
<< " is less than median of last " << m_currency.timestampCheckWindow(b.majorVersion) << " blocks, "
<< median_ts << ", i.e. it's too deep in the past";
return false;
}

Expand Down

0 comments on commit 1dc84a3

Please sign in to comment.