mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +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
|
/// Clear all cached transactions for the specified coin
|
||||||
Future<void> clearSharedTransactionCache({required Coin coin}) async {
|
Future<void> clearSharedTransactionCache({required Coin coin}) async {
|
||||||
await deleteAll<dynamic>(boxName: _boxNameTxCache(coin: coin));
|
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: _boxNameSetCache(coin: coin));
|
||||||
await deleteAll<dynamic>(boxName: _boxNameSetSparkCache(coin: coin));
|
await deleteAll<dynamic>(boxName: _boxNameSetSparkCache(coin: coin));
|
||||||
await deleteAll<dynamic>(boxName: _boxNameUsedSerialsCache(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
|
// null check to see if there is a cached set
|
||||||
if (cachedSet == null) {
|
if (cachedSet == null) {
|
||||||
set = {
|
set = {
|
||||||
"setId": groupId,
|
"coinGroupID": int.parse(groupId),
|
||||||
"blockHash": blockhash,
|
"blockHash": blockhash,
|
||||||
"setHash": "",
|
"setHash": "",
|
||||||
"coins": <dynamic>[],
|
"coins": <dynamic>[],
|
||||||
|
@ -259,6 +259,7 @@ class CachedElectrumXClient {
|
||||||
|
|
||||||
/// Clear all cached transactions for the specified coin
|
/// Clear all cached transactions for the specified coin
|
||||||
Future<void> clearSharedTransactionCache({required Coin coin}) async {
|
Future<void> clearSharedTransactionCache({required Coin coin}) async {
|
||||||
|
await DB.instance.clearSharedTransactionCache(coin: coin);
|
||||||
await DB.instance.closeAnonymitySetCacheBox(coin: coin);
|
await DB.instance.closeAnonymitySetCacheBox(coin: coin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,9 +110,11 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
|
|
||||||
final currentId = await electrumXClient.getSparkLatestCoinId();
|
final currentId = await electrumXClient.getSparkLatestCoinId();
|
||||||
final List<Map<String, dynamic>> setMaps = [];
|
final List<Map<String, dynamic>> setMaps = [];
|
||||||
for (int i = 0; i <= currentId; i++) {
|
// for (int i = 0; i <= currentId; i++) {
|
||||||
final set = await electrumXClient.getSparkAnonymitySet(
|
for (int i = currentId; i <= currentId; i++) {
|
||||||
coinGroupId: i.toString(),
|
final set = await electrumXCachedClient.getSparkAnonymitySet(
|
||||||
|
groupId: i.toString(),
|
||||||
|
coin: info.coin,
|
||||||
);
|
);
|
||||||
set["coinGroupID"] = i;
|
set["coinGroupID"] = i;
|
||||||
setMaps.add(set);
|
setMaps.add(set);
|
||||||
|
@ -423,10 +425,10 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
|
|
||||||
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
||||||
|
|
||||||
// TODO improve performance by adding these calls to the cached client
|
|
||||||
final futureResults = await Future.wait([
|
final futureResults = await Future.wait([
|
||||||
electrumXClient.getSparkAnonymitySet(
|
electrumXCachedClient.getSparkAnonymitySet(
|
||||||
coinGroupId: latestSparkCoinId.toString(),
|
groupId: latestSparkCoinId.toString(),
|
||||||
|
coin: info.coin,
|
||||||
),
|
),
|
||||||
electrumXClient.getSparkUsedCoinsTags(
|
electrumXClient.getSparkUsedCoinsTags(
|
||||||
startNumber: 0,
|
startNumber: 0,
|
||||||
|
@ -542,9 +544,9 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface {
|
||||||
|
|
||||||
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
||||||
|
|
||||||
// TODO improve performance by adding this call to the cached client
|
final anonymitySet = await electrumXCachedClient.getSparkAnonymitySet(
|
||||||
final anonymitySet = await electrumXClient.getSparkAnonymitySet(
|
groupId: latestSparkCoinId.toString(),
|
||||||
coinGroupId: latestSparkCoinId.toString(),
|
coin: info.coin,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO loop over set and see which coins are ours using the FFI call `identifyCoin`
|
// TODO loop over set and see which coins are ours using the FFI call `identifyCoin`
|
||||||
|
|
Loading…
Reference in a new issue