From eb119d6a3b526c41aa12ee2cf1359206b0113679 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Sun, 17 May 2020 18:50:40 +0200 Subject: [PATCH] handling of rare but possible situation with wallet sync rewound --- src/wallet/wallet2.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index b3646a78..f0d1bcee 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1229,10 +1229,19 @@ void wallet2::handle_pulled_blocks(size_t& blocks_added, std::atomic& stop //TODO: get_block_hash is slow crypto::hash bl_id = get_block_hash(bl); - if (processed_blocks_count != 1 && height > processed_blocks_count && height != m_minimum_height) - {//internal error: - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false, - "height{" << height <<"} > processed_blocks_count{" << processed_blocks_count << "}"); + if (processed_blocks_count != 1 && height > processed_blocks_count) + { + if (height != m_minimum_height) + { + //internal error: + WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(false, + "height{" << height << "} > processed_blocks_count{" << processed_blocks_count << "}"); + } + else + { + //possible case, wallet rewound to m_minimum_height + m_chain.clear(); + } } else if (height == processed_blocks_count) {