diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-06-08 14:22:27 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-08-28 14:53:29 +0000 |
commit | 11f13da8b48d9b9dffc036c2fdf862607fbd3edc (patch) | |
tree | 5aa2d28d15a7bebe3a1dbc58df3fffef898dc1bb /src/cryptonote_core/blockchain.cpp | |
parent | Merge pull request #5707 (diff) | |
download | monero-11f13da8b48d9b9dffc036c2fdf862607fbd3edc.tar.xz |
blockchain: fix logging bad number of blocks if first one fails
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index dab1a0a96..e2fa0d8ef 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -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) |