mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-18 16:44:32 +00:00
cached spark anon set electrumx call fixes and usage
This commit is contained in:
parent
7dcac56a5a
commit
e1241372bf
3 changed files with 14 additions and 11 deletions
|
@ -228,7 +228,7 @@ class DB {
|
|||
/// Clear all cached transactions for the specified coin
|
||||
Future<void> clearSharedTransactionCache({required Coin coin}) async {
|
||||
await deleteAll<dynamic>(boxName: _boxNameTxCache(coin: coin));
|
||||
if (coin == Coin.firo) {
|
||||
if (coin == Coin.firo || coin == Coin.firoTestNet) {
|
||||
await deleteAll<dynamic>(boxName: _boxNameSetCache(coin: coin));
|
||||
await deleteAll<dynamic>(boxName: _boxNameSetSparkCache(coin: coin));
|
||||
await deleteAll<dynamic>(boxName: _boxNameUsedSerialsCache(coin: coin));
|
||||
|
|
|
@ -121,7 +121,7 @@ class CachedElectrumXClient {
|
|||
// null check to see if there is a cached set
|
||||
if (cachedSet == null) {
|
||||
set = {
|
||||
"setId": groupId,
|
||||
"coinGroupID": int.parse(groupId),
|
||||
"blockHash": blockhash,
|
||||
"setHash": "",
|
||||
"coins": <dynamic>[],
|
||||
|
@ -259,6 +259,7 @@ class CachedElectrumXClient {
|
|||
|
||||
/// Clear all cached transactions for the specified coin
|
||||
Future<void> clearSharedTransactionCache({required Coin coin}) async {
|
||||
await DB.instance.clearSharedTransactionCache(coin: coin);
|
||||
await DB.instance.closeAnonymitySetCacheBox(coin: coin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,9 +110,11 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
|||
|
||||
final currentId = await electrumXClient.getSparkLatestCoinId();
|
||||
final List<Map<String, dynamic>> setMaps = [];
|
||||
for (int i = 0; i <= currentId; i++) {
|
||||
final set = await electrumXClient.getSparkAnonymitySet(
|
||||
coinGroupId: i.toString(),
|
||||
// for (int i = 0; i <= currentId; i++) {
|
||||
for (int i = currentId; i <= currentId; i++) {
|
||||
final set = await electrumXCachedClient.getSparkAnonymitySet(
|
||||
groupId: i.toString(),
|
||||
coin: info.coin,
|
||||
);
|
||||
set["coinGroupID"] = i;
|
||||
setMaps.add(set);
|
||||
|
@ -423,10 +425,10 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
|||
|
||||
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
||||
|
||||
// TODO improve performance by adding these calls to the cached client
|
||||
final futureResults = await Future.wait([
|
||||
electrumXClient.getSparkAnonymitySet(
|
||||
coinGroupId: latestSparkCoinId.toString(),
|
||||
electrumXCachedClient.getSparkAnonymitySet(
|
||||
groupId: latestSparkCoinId.toString(),
|
||||
coin: info.coin,
|
||||
),
|
||||
electrumXClient.getSparkUsedCoinsTags(
|
||||
startNumber: 0,
|
||||
|
@ -542,9 +544,9 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
|||
|
||||
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
||||
|
||||
// TODO improve performance by adding this call to the cached client
|
||||
final anonymitySet = await electrumXClient.getSparkAnonymitySet(
|
||||
coinGroupId: latestSparkCoinId.toString(),
|
||||
final anonymitySet = await electrumXCachedClient.getSparkAnonymitySet(
|
||||
groupId: latestSparkCoinId.toString(),
|
||||
coin: info.coin,
|
||||
);
|
||||
|
||||
// TODO loop over set and see which coins are ours using the FFI call `identifyCoin`
|
||||
|
|
Loading…
Reference in a new issue