fix broken used serials call and optimize cache a bit

This commit is contained in:
julian 2023-07-25 20:28:27 -06:00
parent 5d3e976601
commit c3054ca753

View file

@ -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",