Merge pull request #2342

2e338ca5 wallet2: account for huge testnet reorgs for estimating height (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-09-02 11:29:53 +02:00
commit 2560948f69
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 3 additions and 0 deletions

View File

@ -5098,6 +5098,9 @@ uint64_t wallet2::get_approximate_blockchain_height() const
const int seconds_per_block = DIFFICULTY_TARGET_V2;
// Calculated blockchain height
uint64_t approx_blockchain_height = fork_block + (time(NULL) - fork_time)/seconds_per_block;
// testnet got some huge rollbacks, so the estimation is way off
if (m_testnet && approx_blockchain_height > 105000)
approx_blockchain_height -= 105000;
LOG_PRINT_L2("Calculated blockchain height: " << approx_blockchain_height);
return approx_blockchain_height;
}