mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +00:00
fix broken used serials call and optimize cache a bit
This commit is contained in:
parent
5d3e976601
commit
c3054ca753
1 changed files with 12 additions and 8 deletions
|
@ -164,14 +164,16 @@ class CachedElectrumX {
|
|||
|
||||
final _list = box.get("serials") as List?;
|
||||
|
||||
List<String> cachedSerials =
|
||||
_list == null ? [] : List<String>.from(_list);
|
||||
Set<String> cachedSerials =
|
||||
_list == null ? {} : List<String>.from(_list).toSet();
|
||||
|
||||
final startNumber = cachedSerials.length;
|
||||
// startNumber is broken currently
|
||||
final startNumber = 0; // cachedSerials.length;
|
||||
|
||||
final serials =
|
||||
await electrumXClient.getUsedCoinSerials(startNumber: startNumber);
|
||||
List<String> newSerials = [];
|
||||
final serials = await electrumXClient.getUsedCoinSerials(
|
||||
startNumber: startNumber,
|
||||
);
|
||||
Set<String> newSerials = {};
|
||||
|
||||
for (final element in (serials["serials"] as List)) {
|
||||
if (!isHexadecimal(element as String)) {
|
||||
|
@ -182,12 +184,14 @@ class CachedElectrumX {
|
|||
}
|
||||
cachedSerials.addAll(newSerials);
|
||||
|
||||
final resultingList = cachedSerials.toList();
|
||||
|
||||
await box.put(
|
||||
"serials",
|
||||
cachedSerials,
|
||||
resultingList,
|
||||
);
|
||||
|
||||
return cachedSerials;
|
||||
return resultingList;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"Failed to process CachedElectrumX.getTransaction(): $e\n$s",
|
||||
|
|
Loading…
Reference in a new issue