summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCzarek Nakamoto <cyjan@mrcyjanek.net>2024-01-03 13:24:07 +0100
committerCzarek Nakamoto <cyjan@mrcyjanek.net>2024-01-03 13:24:07 +0100
commit476c3a43e46f9ddbf18a089c1b32d00642308737 (patch)
tree923fac6b5720747cd6c2e16648426fb9fa2ddfd9
parent41a470c19e15f0ee238a47d32b04ad64cce42ea5 (diff)
Make the process run a bit differently,
let's delay the task to the Isolate.run as std::thread was causing some funky crashes that I'm in no mood to fix atm
-rw-r--r--libbridge/src/main/cpp/wallet2_api_c.cpp21
1 files changed, 4 insertions, 17 deletions
diff --git a/libbridge/src/main/cpp/wallet2_api_c.cpp b/libbridge/src/main/cpp/wallet2_api_c.cpp
index ce9c210..6faa922 100644
--- a/libbridge/src/main/cpp/wallet2_api_c.cpp
+++ b/libbridge/src/main/cpp/wallet2_api_c.cpp
@@ -955,30 +955,17 @@ uint64_t MONERO_Wallet_daemonBlockChainHeight_cached(void* wallet_ptr) {
return daemonBlockChainHeight_cached;
}
-uint64_t daemonBlockChainHeight_cahceSleepTime = 1;
-bool daemonBlockChainHeight_cahceIsEnabled = false;
+bool daemonBlockChainHeight_cacheIsEnabled = false;
-void MONERO_Wallet_daemonBlockChainHeight_runThread(void* wallet_ptr) {
+void MONERO_Wallet_daemonBlockChainHeight_runThread(void* wallet_ptr, int seconds) {
while (true) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
daemonBlockChainHeight_cached = wallet->daemonBlockChainHeight();
- sleep(daemonBlockChainHeight_cahceSleepTime);
- std::cout << "MONERO: TICK: MONERO_Wallet_daemonBlockChainHeight_runThread: " << daemonBlockChainHeight_cached << std::endl;
+ sleep(seconds);
+ std::cout << "MONERO: TICK: MONERO_Wallet_daemonBlockChainHeight_runThread(" << seconds << "): " << daemonBlockChainHeight_cached << std::endl;
}
}
-bool MONERO_Wallet_daemonBlockChainHeight_enableRefresh(void* wallet_ptr, int seconds) {
- if (seconds < 1) {
- seconds = 1;
- }
- daemonBlockChainHeight_cahceSleepTime = seconds;
- if (daemonBlockChainHeight_cahceIsEnabled == true) {
- return true;
- }
- daemonBlockChainHeight_cahceIsEnabled = true;
- std::thread t1(MONERO_Wallet_daemonBlockChainHeight_runThread, wallet_ptr);
- return true;
-}
uint64_t MONERO_Wallet_daemonBlockChainTargetHeight(void* wallet_ptr) {
Monero::Wallet *wallet = reinterpret_cast<Monero::Wallet*>(wallet_ptr);
return wallet->daemonBlockChainTargetHeight();