BlockCache: fixed collisions of same height blocks

This commit is contained in:
SChernykh
2022-03-24 16:03:12 +01:00
parent cdc3206ee8
commit 8b27faad6d
3 changed files with 14 additions and 10 deletions

View File

@@ -154,6 +154,7 @@ struct BlockCache::Impl : public nocopy_nomove
BlockCache::BlockCache()
: m_impl(new Impl())
, m_flushRunning(0)
, m_storeIndex(0)
{
}
@@ -171,7 +172,7 @@ void BlockCache::store(const PoolBlock& block)
return;
}
uint8_t* data = m_impl->m_data + (static_cast<size_t>(block.m_sidechainHeight % NUM_BLOCKS) * BLOCK_SIZE);
uint8_t* data = m_impl->m_data + (static_cast<size_t>((m_storeIndex++) % NUM_BLOCKS) * BLOCK_SIZE);
*reinterpret_cast<uint32_t*>(data) = static_cast<uint32_t>(n1 + n2);
memcpy(data + sizeof(uint32_t), block.m_mainChainData.data(), n1);