mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Skip unneeded blocks in fast refresh
This commit is contained in:
parent
fd18ad1e60
commit
3d25c90053
1 changed files with 10 additions and 2 deletions
|
@ -3317,11 +3317,19 @@ void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height,
|
||||||
{
|
{
|
||||||
std::vector<crypto::hash> hashes;
|
std::vector<crypto::hash> hashes;
|
||||||
|
|
||||||
const uint64_t checkpoint_height = m_checkpoints.get_max_height();
|
// Get highest checkpoint that is lower than stop_height
|
||||||
|
uint64_t checkpoint_height = 0;
|
||||||
|
for (auto i : m_checkpoints.get_points()) {
|
||||||
|
if (i.first > stop_height) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
checkpoint_height = i.first;
|
||||||
|
}
|
||||||
|
|
||||||
if ((stop_height > checkpoint_height && m_blockchain.size()-1 < checkpoint_height) && !force)
|
if ((stop_height > checkpoint_height && m_blockchain.size()-1 < checkpoint_height) && !force)
|
||||||
{
|
{
|
||||||
// we will drop all these, so don't bother getting them
|
// we will drop all these, so don't bother getting them
|
||||||
uint64_t missing_blocks = m_checkpoints.get_max_height() - m_blockchain.size();
|
uint64_t missing_blocks = checkpoint_height - m_blockchain.size();
|
||||||
while (missing_blocks-- > 0)
|
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(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_blockchain.push_back(m_checkpoints.get_points().at(checkpoint_height));
|
||||||
|
|
Loading…
Reference in a new issue