aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-11-14 15:21:57 +0200
committerRiccardo Spagni <ric@spagni.net>2017-11-14 15:21:58 +0200
commit29d77e5686a0c124678e27b07502709f5ce8cf6e (patch)
treee2afeadb1d07197d24458e2a73fd12c0dab1829b /src
parentMerge pull request #2624 (diff)
parentwallet2: do not bother downloading block hashes below last checkpoint (diff)
downloadmonero-29d77e5686a0c124678e27b07502709f5ce8cf6e.tar.xz
Merge pull request #2727
9d6c6c5d wallet2: do not bother downloading block hashes below last checkpoint (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet2.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 5467ea7cb..a7161ffcb 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -1789,8 +1789,21 @@ void wallet2::update_pool_state(bool refreshed)
void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history)
{
std::list<crypto::hash> hashes;
- size_t current_index = m_blockchain.size();
+ const uint64_t checkpoint_height = m_checkpoints.get_max_height();
+ if (stop_height > checkpoint_height && m_blockchain.size()-1 < checkpoint_height)
+ {
+ // we will drop all these, so don't bother getting them
+ uint64_t missing_blocks = m_checkpoints.get_max_height() - m_blockchain.size();
+ while (missing_blocks-- > 0)
+ m_blockchain.push_back(crypto::null_hash); // maybe a bit suboptimal, but deque won't do huge reallocs like vector
+ m_blockchain.push_back(m_checkpoints.get_points().at(checkpoint_height));
+ m_local_bc_height = m_blockchain.size();
+ short_chain_history.clear();
+ get_short_chain_history(short_chain_history);
+ }
+
+ size_t current_index = m_blockchain.size();
while(m_run.load(std::memory_order_relaxed) && current_index < stop_height)
{
pull_hashes(0, blocks_start_height, short_chain_history, hashes);