summaryrefslogtreecommitdiff
path: root/impls/monero.dart/lib/wownero.dart
diff options
context:
space:
mode:
authorKonstantin Ullrich <konstantinullrich12@gmail.com>2024-10-07 12:37:30 +0200
committerKonstantin Ullrich <konstantinullrich12@gmail.com>2024-10-07 12:37:30 +0200
commit98272ee381bd07081502dd426226f58c879300a6 (patch)
tree672f6f06727dbc1c84270973ce13e9403913e481 /impls/monero.dart/lib/wownero.dart
parent04b29d84a2c368c677cf5ec946269203622ca170 (diff)
parent67f4baa015a4407d096e35b6e5a81d72932fb55f (diff)
Merge branch 'master' into ledger
# Conflicts: # .github/workflows/full_check.yaml # impls/monero.dart/lib/monero.dart # impls/monero.dart/pubspec.yaml # patches/monero/0016-add-dummy-device-for-ledger.patch
Diffstat (limited to 'impls/monero.dart/lib/wownero.dart')
-rw-r--r--impls/monero.dart/lib/wownero.dart46
1 files changed, 35 insertions, 11 deletions
diff --git a/impls/monero.dart/lib/wownero.dart b/impls/monero.dart/lib/wownero.dart
index 5a0a288..d355005 100644
--- a/impls/monero.dart/lib/wownero.dart
+++ b/impls/monero.dart/lib/wownero.dart
@@ -101,14 +101,36 @@ final Stopwatch sw = Stopwatch()..start();
bool printStarts = false;
void Function(String call)? debugStart = (call) {
- if (printStarts) print("MONERO: $call");
- debugCallLength[call] ??= <int>[];
- debugCallLength[call]!.add(sw.elapsedMicroseconds);
+ try {
+ if (printStarts) print("MONERO: $call");
+ debugCallLength[call] ??= <int>[];
+ debugCallLength[call]!.add(sw.elapsedMicroseconds);
+ } catch (e) {}
};
+void debugChores() {
+ for (var key in debugCallLength.keys) {
+ if (debugCallLength[key]!.length > 1000000) {
+ final elm =
+ debugCallLength[key]!.reduce((value, element) => value + element);
+ debugCallLength[key]!.clear();
+ debugCallLength["${key}_1M"] ??= <int>[];
+ debugCallLength["${key}_1M"]!.add(elm);
+ }
+ }
+}
+
+int debugCount = 0;
+
void Function(String call)? debugEnd = (call) {
- final id = debugCallLength[call]!.length - 1;
- debugCallLength[call]![id] =
- sw.elapsedMicroseconds - debugCallLength[call]![id];
+ try {
+ final id = debugCallLength[call]!.length - 1;
+ if (++debugCount > 1000000) {
+ debugCount = 0;
+ debugChores();
+ }
+ debugCallLength[call]![id] =
+ sw.elapsedMicroseconds - debugCallLength[call]![id];
+ } catch (e) {}
};
void Function(String call, dynamic error)? errorHandler = (call, error) {
print("$call: $error");
@@ -3220,7 +3242,8 @@ bool WalletManager_verifyWalletPassword(
return s;
}
-String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) {
+List<String> WalletManager_findWallets(WalletManager wm_ptr,
+ {required String path}) {
debugStart?.call('WOWNERO_WalletManager_findWallets');
lib ??= WowneroC(DynamicLibrary.open(libPath));
try {
@@ -3230,13 +3253,15 @@ String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) {
.cast<Utf8>();
final str = strPtr.toDartString();
calloc.free(path_);
- WOWNERO_free(strPtr.cast());
+ if (str.isNotEmpty) {
+ WOWNERO_free(strPtr.cast());
+ }
debugEnd?.call('WOWNERO_WalletManager_findWallets');
- return str;
+ return str.split(";");
} catch (e) {
errorHandler?.call('WOWNERO_WalletManager_findWallets', e);
debugEnd?.call('WOWNERO_WalletManager_findWallets');
- return "";
+ return [];
}
}
@@ -3606,7 +3631,6 @@ int WOWNERO_deprecated_14WordSeedHeight({
return s;
}
-
String WOWNERO_checksum_wallet2_api_c_h() {
debugStart?.call('WOWNERO_checksum_wallet2_api_c_h');
lib ??= WowneroC(DynamicLibrary.open(libPath));