fix spark cache coins order

This commit is contained in:
julian 2024-06-06 11:21:50 -06:00
parent eb13c2dc00
commit 1ffddc6781
4 changed files with 31 additions and 21 deletions

View file

@ -120,15 +120,32 @@ abstract class FiroCacheCoordinator {
);
}
static Future<ResultSet> getSetCoinsForGroupId(
static Future<
List<
({
String serialized,
String txHash,
String context,
})>> getSetCoinsForGroupId(
int groupId, {
int? newerThanTimeStamp,
}) async {
return await _Reader._getSetCoinsForGroupId(
final resultSet = await _Reader._getSetCoinsForGroupId(
groupId,
db: _FiroCache.setCacheDB,
newerThanTimeStamp: newerThanTimeStamp,
);
return resultSet
.map(
(row) => (
serialized: row["serialized"] as String,
txHash: row["txHash"] as String,
context: row["context"] as String,
),
)
.toList()
.reversed
.toList();
}
static Future<

View file

@ -104,7 +104,8 @@ FCResult _updateSparkAnonSetCoinsWith(
e[2] as String,
],
)
.toList();
.toList()
.reversed;
final timestamp = DateTime.now().toUtc().millisecondsSinceEpoch ~/ 1000;

View file

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'package:isar/isar.dart';
import 'package:meta/meta.dart';
@ -560,15 +559,8 @@ abstract class Wallet<T extends CryptoCurrency> {
// TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided.
if (this is LelantusInterface) {
// Parse otherDataJsonString to get the enableLelantusScanning value.
bool enableLelantusScanning = false;
if (this.info.otherDataJsonString != null) {
final otherDataJson = json.decode(this.info.otherDataJsonString!);
enableLelantusScanning =
otherDataJson[WalletInfoKeys.enableLelantusScanning] as bool? ??
false;
}
if (enableLelantusScanning) {
if (info.otherData[WalletInfoKeys.enableLelantusScanning] as bool? ??
false) {
await (this as LelantusInterface).refreshLelantusData();
}
}

View file

@ -297,10 +297,10 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
"coinGroupID": i,
"coins": resultSet
.map(
(row) => [
row["serialized"] as String,
row["txHash"] as String,
row["context"] as String,
(e) => [
e.serialized,
e.txHash,
e.context,
],
)
.toList(),
@ -799,10 +799,10 @@ mixin SparkInterface<T extends ElectrumXCurrencyInterface>
);
final coinsRaw = anonymitySetResult
.map(
(row) => [
row["serialized"] as String,
row["txHash"] as String,
row["context"] as String,
(e) => [
e.serialized,
e.txHash,
e.context,
],
)
.toList();