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?;
|
final _list = box.get("serials") as List?;
|
||||||
|
|
||||||
List<String> cachedSerials =
|
Set<String> cachedSerials =
|
||||||
_list == null ? [] : List<String>.from(_list);
|
_list == null ? {} : List<String>.from(_list).toSet();
|
||||||
|
|
||||||
final startNumber = cachedSerials.length;
|
// startNumber is broken currently
|
||||||
|
final startNumber = 0; // cachedSerials.length;
|
||||||
|
|
||||||
final serials =
|
final serials = await electrumXClient.getUsedCoinSerials(
|
||||||
await electrumXClient.getUsedCoinSerials(startNumber: startNumber);
|
startNumber: startNumber,
|
||||||
List<String> newSerials = [];
|
);
|
||||||
|
Set<String> newSerials = {};
|
||||||
|
|
||||||
for (final element in (serials["serials"] as List)) {
|
for (final element in (serials["serials"] as List)) {
|
||||||
if (!isHexadecimal(element as String)) {
|
if (!isHexadecimal(element as String)) {
|
||||||
|
@ -182,12 +184,14 @@ class CachedElectrumX {
|
||||||
}
|
}
|
||||||
cachedSerials.addAll(newSerials);
|
cachedSerials.addAll(newSerials);
|
||||||
|
|
||||||
|
final resultingList = cachedSerials.toList();
|
||||||
|
|
||||||
await box.put(
|
await box.put(
|
||||||
"serials",
|
"serials",
|
||||||
cachedSerials,
|
resultingList,
|
||||||
);
|
);
|
||||||
|
|
||||||
return cachedSerials;
|
return resultingList;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"Failed to process CachedElectrumX.getTransaction(): $e\n$s",
|
"Failed to process CachedElectrumX.getTransaction(): $e\n$s",
|
||||||
|
|
Loading…
Reference in a new issue