blockchain: fix logging bad number of blocks if first one fails

This commit is contained in:
moneromooo-monero 2019-06-08 14:22:27 +00:00
parent 85014813cf
commit 11f13da8b4
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 3 additions and 2 deletions

View File

@ -616,7 +616,7 @@ bool Blockchain::deinit()
// It starts a batch and calls private method pop_block_from_blockchain().
void Blockchain::pop_blocks(uint64_t nblocks)
{
uint64_t i;
uint64_t i = 0;
CRITICAL_REGION_LOCAL(m_tx_pool);
CRITICAL_REGION_LOCAL1(m_blockchain_lock);
@ -627,9 +627,10 @@ void Blockchain::pop_blocks(uint64_t nblocks)
const uint64_t blockchain_height = m_db->height();
if (blockchain_height > 0)
nblocks = std::min(nblocks, blockchain_height - 1);
for (i=0; i < nblocks; ++i)
while (i < nblocks)
{
pop_block_from_blockchain();
++i;
}
}
catch (const std::exception& e)