@@ -23,7 +23,13 @@ abstract class FiroCacheCoordinator {
2323 }
2424 }
2525
26- static Future <void > clearSharedCache (CryptoCurrencyNetwork network) async {
26+ static Future <void > clearSharedCache (
27+ CryptoCurrencyNetwork network, {
28+ bool clearOnlyUsedTagsCache = false ,
29+ }) async {
30+ if (clearOnlyUsedTagsCache) {
31+ return await _FiroCache ._deleteUsedTagsCache (network);
32+ }
2733 return await _FiroCache ._deleteAllCache (network);
2834 }
2935
@@ -38,9 +44,10 @@ abstract class FiroCacheCoordinator {
3844
3945 final setSize =
4046 (await setCacheFile.exists ()) ? await setCacheFile.length () : 0 ;
41- final tagsSize = (await usedTagsCacheFile.exists ())
42- ? await usedTagsCacheFile.length ()
43- : 0 ;
47+ final tagsSize =
48+ (await usedTagsCacheFile.exists ())
49+ ? await usedTagsCacheFile.length ()
50+ : 0 ;
4451
4552 Logging .instance.d ("Spark cache used tags size: $tagsSize " );
4653 Logging .instance.d ("Spark cache anon set size: $setSize " );
@@ -67,16 +74,11 @@ abstract class FiroCacheCoordinator {
6774 ) async {
6875 await _tagLocks[network]! .protect (() async {
6976 final count = await FiroCacheCoordinator .getUsedCoinTagsCount (network);
70- final unhashedTags =
71- await client.getSparkUnhashedUsedCoinsTagsWithTxHashes (
72- startNumber: count,
73- );
77+ final unhashedTags = await client
78+ .getSparkUnhashedUsedCoinsTagsWithTxHashes (startNumber: count);
7479 if (unhashedTags.isNotEmpty) {
7580 await _workers[network]! .runTask (
76- FCTask (
77- func: FCFuncName ._updateSparkUsedTagsWith,
78- data: unhashedTags,
79- ),
81+ FCTask (func: FCFuncName ._updateSparkUsedTagsWith, data: unhashedTags),
8082 );
8183 }
8284 });
@@ -98,9 +100,7 @@ abstract class FiroCacheCoordinator {
98100
99101 final prevSize = prevMeta? .size ?? 0 ;
100102
101- final meta = await client.getSparkAnonymitySetMeta (
102- coinGroupId: groupId,
103- );
103+ final meta = await client.getSparkAnonymitySetMeta (coinGroupId: groupId);
104104
105105 progressUpdated? .call (prevSize, meta.size);
106106
@@ -141,9 +141,10 @@ abstract class FiroCacheCoordinator {
141141 coins.addAll (data);
142142 }
143143
144- final result = coins
145- .map ((e) => RawSparkCoin .fromRPCResponse (e as List , groupId))
146- .toList ();
144+ final result =
145+ coins
146+ .map ((e) => RawSparkCoin .fromRPCResponse (e as List , groupId))
147+ .toList ();
147148
148149 await _workers[network]! .runTask (
149150 FCTask (
@@ -156,20 +157,18 @@ abstract class FiroCacheCoordinator {
156157
157158 // ===========================================================================
158159
159- static Future <Set <String >> getUsedCoinTags (
160+ static Future <List <String >> getUsedCoinTags (
160161 int startNumber,
161162 CryptoCurrencyNetwork network,
162163 ) async {
163164 final result = await _Reader ._getSparkUsedCoinTags (
164165 startNumber,
165166 db: _FiroCache .usedTagsCacheDB (network),
166167 );
167- return result.map ((e) => e["tag" ] as String ).toSet ();
168+ return result.map ((e) => e["tag" ] as String ).toList ();
168169 }
169170
170- static Future <int > getUsedCoinTagsCount (
171- CryptoCurrencyNetwork network,
172- ) async {
171+ static Future <int > getUsedCoinTagsCount (CryptoCurrencyNetwork network) async {
173172 final result = await _Reader ._getUsedCoinTagsCount (
174173 db: _FiroCache .usedTagsCacheDB (network),
175174 );
@@ -195,24 +194,19 @@ abstract class FiroCacheCoordinator {
195194 return [];
196195 }
197196 return result.rows
198- .map (
199- (e) => (
200- tag: e[0 ] as String ,
201- txid: e[1 ] as String ,
202- ),
203- )
197+ .map ((e) => (tag: e[0 ] as String , txid: e[1 ] as String ))
204198 .toList ();
205199 }
206200
207- static Future <Set <String >> getUsedCoinTagsFor ({
201+ static Future <List <String >> getUsedCoinTagsFor ({
208202 required String txid,
209203 required CryptoCurrencyNetwork network,
210204 }) async {
211205 final result = await _Reader ._getUsedCoinTagsFor (
212206 txid,
213207 db: _FiroCache .usedTagsCacheDB (network),
214208 );
215- return result.map ((e) => e["tag" ] as String ).toSet ();
209+ return result.map ((e) => e["tag" ] as String ).toList ();
216210 }
217211
218212 static Future <bool > checkTagIsUsed (
@@ -230,16 +224,17 @@ abstract class FiroCacheCoordinator {
230224 String ? afterBlockHash,
231225 required CryptoCurrencyNetwork network,
232226 }) async {
233- final resultSet = afterBlockHash == null
234- ? await _Reader ._getSetCoinsForGroupId (
235- groupId,
236- db: _FiroCache .setCacheDB (network),
237- )
238- : await _Reader ._getSetCoinsForGroupIdAndBlockHash (
239- groupId,
240- afterBlockHash,
241- db: _FiroCache .setCacheDB (network),
242- );
227+ final resultSet =
228+ afterBlockHash == null
229+ ? await _Reader ._getSetCoinsForGroupId (
230+ groupId,
231+ db: _FiroCache .setCacheDB (network),
232+ )
233+ : await _Reader ._getSetCoinsForGroupIdAndBlockHash (
234+ groupId,
235+ afterBlockHash,
236+ db: _FiroCache .setCacheDB (network),
237+ );
243238
244239 return resultSet
245240 .map (
0 commit comments