mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00: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
1 changed files with 2 additions and 4 deletions
|
@ -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 a new issue