diff options
| author | tobtoht <tob@featherwallet.org> | 2026-05-13 11:12:25 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2026-05-13 11:12:25 +0000 |
| commit | 12c8ccf57fefceac40a10966fb5f0905830e7402 (patch) | |
| tree | 18c6880414ba64703d5f009bde64472bf4650fbe /src/wallet/wallet2.cpp | |
| parent | 2567d30cecf10e50f28a9b5a6d2e7a08cfe36545 (diff) | |
| parent | afb9a1f152779d3ae48a23caaec7dcfc28081927 (diff) | |
| download | monzero-core-12c8ccf57fefceac40a10966fb5f0905830e7402.tar.gz monzero-core-12c8ccf57fefceac40a10966fb5f0905830e7402.tar.xz monzero-core-12c8ccf57fefceac40a10966fb5f0905830e7402.zip | |
Merge pull request #10580
afb9a1f use latest hard fork block for get_approximate_blockchain_height & update approximate_rolled_back_blocks (SNeedlewoods)
Diffstat (limited to 'src/wallet/wallet2.cpp')
| -rw-r--r-- | src/wallet/wallet2.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 723635481..66b3f1bfc 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -13584,17 +13584,26 @@ uint64_t wallet2::get_daemon_blockchain_target_height(string &err) uint64_t wallet2::get_approximate_blockchain_height() const { - // time of v2 fork - const time_t fork_time = m_nettype == TESTNET ? 1448285909 : m_nettype == STAGENET ? 1520937818 : 1458748658; - // v2 fork block - const uint64_t fork_block = m_nettype == TESTNET ? 624634 : m_nettype == STAGENET ? 32000 : 1009827; + const size_t wallet_num_hard_forks = m_nettype == TESTNET ? num_testnet_hard_forks + : m_nettype == STAGENET ? num_stagenet_hard_forks + : num_mainnet_hard_forks; + const hardfork_t *wallet_hard_forks = m_nettype == TESTNET ? testnet_hard_forks + : m_nettype == STAGENET ? stagenet_hard_forks + : mainnet_hard_forks; + // time of latest fork + const time_t fork_time = wallet_hard_forks[wallet_num_hard_forks-1].time; + // latest fork block + const uint64_t fork_block = wallet_hard_forks[wallet_num_hard_forks-1].height; // avg seconds per block 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; + uint64_t approx_blockchain_height = fork_block; + const time_t now = time(NULL); + if (now > fork_time) + approx_blockchain_height += (now - fork_time) / seconds_per_block; // testnet and stagenet got some huge rollbacks, so the estimation is way off - static const uint64_t approximate_rolled_back_blocks = m_nettype == TESTNET ? 342100 : m_nettype == STAGENET ? 60000 : 30000; - if ((m_nettype == TESTNET || m_nettype == STAGENET) && approx_blockchain_height > approximate_rolled_back_blocks) + const uint64_t approximate_rolled_back_blocks = m_nettype == TESTNET ? 26600 : m_nettype == STAGENET ? 48600 : 33600; + if (approx_blockchain_height > approximate_rolled_back_blocks) approx_blockchain_height -= approximate_rolled_back_blocks; LOG_PRINT_L2("Calculated blockchain height: " << approx_blockchain_height); return approx_blockchain_height; |
