support wallet sync rate

This commit is contained in:
woodser
2020-12-20 12:57:19 -05:00
parent 9d191fcc5e
commit ff19218059
3 changed files with 7 additions and 6 deletions
+4 -2
View File
@@ -460,9 +460,11 @@ namespace monero {
}
/**
* Start an asynchronous thread to continuously synchronize the wallet with the daemon.
* Start background synchronizing with a maximum number of seconds between syncs.
*
* @param sync_rate_in_seconds - maximum number of seconds between wallet syncs for updates (default 10 seconds)
*/
virtual void start_syncing() {
virtual void start_syncing(uint32_t sync_rate_in_seconds = 10) {
throw std::runtime_error("start_syncing() not supported");
}
+2 -3
View File
@@ -76,7 +76,6 @@ namespace monero {
// ------------------------- INITIALIZE CONSTANTS ---------------------------
static const int DEFAULT_SYNC_INTERVAL_MILLIS = 1000 * 10; // default refresh interval 10 sec
static const int DEFAULT_CONNECTION_TIMEOUT_MILLIS = 1000 * 30; // default connection timeout 30 sec
static const bool STRICT = false; // relies exclusively on blockchain data if true, includes local wallet data if false TODO: good use case to expose externally?
@@ -1376,8 +1375,9 @@ namespace monero {
/**
* Start automatic syncing as its own thread.
*/
void monero_wallet_core::start_syncing() {
void monero_wallet_core::start_syncing(uint32_t sync_rate_in_seconds) {
if (!m_is_connected) throw std::runtime_error("Wallet is not connected to daemon");
m_syncing_interval = sync_rate_in_seconds * 1000; // set sync rate // TODO: use ms instead of seconds?
if (!m_syncing_enabled) {
m_syncing_enabled = true;
run_sync_loop(); // sync wallet on loop in background
@@ -3209,7 +3209,6 @@ namespace monero {
m_rescan_on_sync = false;
m_syncing_enabled = false;
m_sync_loop_running = false;
m_syncing_interval = DEFAULT_SYNC_INTERVAL_MILLIS;
}
std::vector<std::shared_ptr<monero_transfer>> monero_wallet_core::get_transfers_aux(const monero_transfer_query& query) const {
+1 -1
View File
@@ -204,7 +204,7 @@ namespace monero {
monero_sync_result sync(monero_wallet_listener& listener) override;
monero_sync_result sync(uint64_t start_height) override;
monero_sync_result sync(uint64_t start_height, monero_wallet_listener& listener) override;
void start_syncing() override;
void start_syncing(uint32_t sync_rate) override;
void stop_syncing() override;
void rescan_spent() override;
void rescan_blockchain() override;