From 30c92decc268f230de9410d17240fe4c63085e54 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 18 Jul 2019 07:44:21 -0400 Subject: [PATCH] manually adjust restore height if startHeight < restoreHeight because wallet2 does not process from start height --- src/wallet/MoneroWallet.cpp | 31 ++++++++++++++++++++++++++++--- src/wallet/MoneroWallet.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index b308f4b..82975df 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -684,7 +684,7 @@ namespace monero { } virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index, uint64_t unlock_time) { - cout << "Wallet2Listener::on_money_received()" << endl; + //cout << "Wallet2Listener::on_money_received()" << endl; //throw runtime_error("Not implemented"); } @@ -1003,7 +1003,7 @@ namespace monero { void MoneroWallet::setAutoSync(bool autoSync) { cout << "setAutoSync(" << autoSync << ")" << endl; - throw runtime_error("Not implemented"); + //throw runtime_error("Not implemented"); } // rescanBlockchain @@ -2242,7 +2242,31 @@ namespace monero { void MoneroWallet::autoSyncThreadFunc() { cout << "autoSyncThreadFunc()" << endl; - throw runtime_error("autoSyncThreadFunc() not implemented"); +// while (true) { +// boost::mutex::scoped_lock lock(autoSyncMutex); +// if (autoSyncThreadDone) break; +// if (autoSyncEnabled) { +// boost::posix_time::milliseconds wait_for_ms(autoSyncIntervalMillis.load()); +// syncCV.timed_wait(lock, wait_for_ms); +// } else { +// syncCV.wait(lock); +// } +// if (autoSyncEnabled) { +// doRefresh(); +// } +// } + } + + void MoneroWallet::doSync() { +// bool rescan = rescanOnSync.exchange(false); +// boost::lock_guard guarg(syncMutex); +// do { +// if (daemonSynced()) { +// if (rescan) wallet2->rescan_blockchain(false); +// wallet2->refresh(wallet2->is_trusted_daemon()); +// wallet2->find_and_save_rings(false); +// } +// } while (!rescan && (rescan = rescanOnSync.exchange(false))); // repeat if not rescanned and rescan was requested } MoneroSyncResult MoneroWallet::syncAux(boost::optional startHeight, boost::optional endHeight, boost::optional listener) { @@ -2253,6 +2277,7 @@ namespace monero { // determine sync start height uint64_t syncStartHeight = startHeight == boost::none ? max(getHeight(), getRestoreHeight()) : *startHeight; + if (syncStartHeight < getRestoreHeight()) setRestoreHeight(syncStartHeight); // TODO monero core: start height processed > requested start height unless restore height manually set // sync wallet wallet2Listener->onSyncStart(syncStartHeight, listener); diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index ae266e4..5bf496f 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -1162,5 +1162,6 @@ namespace monero { std::mutex autoSyncMutex; // synchronize auto sync loop std::atomic autoSyncThreadDone; // whether or not auto sync loop is done (cannot be re-started) void autoSyncThreadFunc(); // function to run auto sync loop thread + void doSync(); // internal synchronized sync function }; }