From 37c12119ab2fc2119528900e1afd2097ed1a3185 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 1 Oct 2017 16:02:14 +0100 Subject: wallet2: fix hash chain trimming when the inner chain becomes empty It'd prevent further syncing. Recovery of empty hash chains is automatic, but requires a running daemon --- src/wallet/wallet2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/wallet/wallet2.h') diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 83863ca54..1dff14a95 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -108,7 +108,8 @@ namespace tools void crop(size_t height) { m_blockchain.resize(height - m_offset); } void clear() { m_offset = 0; m_blockchain.clear(); } bool empty() const { return m_blockchain.empty() && m_offset == 0; } - void trim(size_t height) { while (height > m_offset && !m_blockchain.empty()) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); } + void trim(size_t height) { while (height > m_offset+1 && m_blockchain.size() > 1) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); } + void refill(const crypto::hash &hash) { m_blockchain.push_back(hash); --m_offset; } template inline void serialize(t_archive &a, const unsigned int ver) -- cgit v1.2.3