diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2022-05-25 09:30:58 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2023-08-17 15:35:00 +0000 |
commit | 356e6877dcd3fcb337ea8ff8c88cf44fbc6a30a6 (patch) | |
tree | 3eaba537c9746333a177f85ec54201feff5d89fd /src/wallet/wallet_rpc_server.cpp | |
parent | wallet_rpc_server: add --no-initial-sync flag for quicker network binding (diff) | |
download | monero-356e6877dcd3fcb337ea8ff8c88cf44fbc6a30a6.tar.xz |
wallet_rpc_server: chunk refresh to keep responding to RPC while refreshing
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r-- | src/wallet/wallet_rpc_server.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 0c30394b1..f08ae82d6 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -60,6 +60,7 @@ using namespace epee; #define MONERO_DEFAULT_LOG_CATEGORY "wallet.rpc" #define DEFAULT_AUTO_REFRESH_PERIOD 20 // seconds +#define REFRESH_INFICATIVE_BLOCK_CHUNK_SIZE 256 // just to split refresh in separate calls to play nicer with other threads #define CHECK_MULTISIG_ENABLED() \ do \ @@ -153,11 +154,14 @@ namespace tools uint64_t blocks_fetched = 0; try { bool received_money = false; - if (m_wallet) m_wallet->refresh(m_wallet->is_trusted_daemon(), 0, blocks_fetched, received_money, true, true); + if (m_wallet) m_wallet->refresh(m_wallet->is_trusted_daemon(), 0, blocks_fetched, received_money, true, REFRESH_INFICATIVE_BLOCK_CHUNK_SIZE, true); } catch (const std::exception& ex) { LOG_ERROR("Exception at while refreshing, what=" << ex.what()); } - m_last_auto_refresh_time = boost::posix_time::microsec_clock::universal_time(); + // if we got the max amount of blocks, do not set the last refresh time, we did only part of the refresh and will + // continue asap, and only set the last refresh time once the refresh is actually finished + if (blocks_fetched < REFRESH_INFICATIVE_BLOCK_CHUNK_SIZE) + m_last_auto_refresh_time = boost::posix_time::microsec_clock::universal_time(); return true; }, 1000); m_net_server.add_idle_handler([this](){ |