mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 13:23:29 +01:00
blockchain: fix off by 1 in timestamp median calculations
The height function apparently used to return the index of the last block, rather than the height of the chain. This now seems to be incorrect, judging the the code, so we remove the now wrong comment, as well as a couple +/- 1 adjustments which now cause the median calculation to differ from the original blockchain_storage version.
This commit is contained in:
parent
f7c27f81af
commit
769d5ef0e6
@ -2218,7 +2218,7 @@ bool Blockchain::check_block_timestamp(const block& b) const
|
||||
}
|
||||
|
||||
// if not enough blocks, no proper median yet, return true
|
||||
if(m_db->height() < BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW + 1)
|
||||
if(m_db->height() < BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -2227,9 +2227,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
|
||||
// using +1 because BlockchainDB::height() returns the index of the top block,
|
||||
// not the size of the blockchain (0-indexed)
|
||||
size_t offset = h - BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW - 1;
|
||||
size_t offset = h - BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW;
|
||||
for(;offset < h; ++offset)
|
||||
{
|
||||
timestamps.push_back(m_db->get_block_timestamp(offset));
|
||||
|
Loading…
Reference in New Issue
Block a user