used tags cache count fix

This commit is contained in:
julian 2024-06-06 14:36:21 -06:00
parent 85f609fa6f
commit 20f743932b
3 changed files with 7 additions and 7 deletions

View file

@ -50,7 +50,7 @@ abstract class FiroCacheCoordinator {
static Future<void> runFetchAndUpdateSparkUsedCoinTags(
ElectrumXClient client,
) async {
final count = await FiroCacheCoordinator.getUsedCoinTagsLastAddedRowId();
final count = await FiroCacheCoordinator.getUsedCoinTagsCount();
final unhashedTags = await client.getSparkUnhashedUsedCoinsTags(
startNumber: count,
);
@ -101,14 +101,14 @@ abstract class FiroCacheCoordinator {
/// Assuming the integrity of the data. Faster than actually calling count on
/// a table where no records have been deleted. None should be deleted from
/// this table in practice.
static Future<int> getUsedCoinTagsLastAddedRowId() async {
final result = await _Reader._getUsedCoinTagsLastAddedRowId(
static Future<int> getUsedCoinTagsCount() async {
final result = await _Reader._getUsedCoinTagsCount(
db: _FiroCache.usedTagsCacheDB,
);
if (result.isEmpty) {
return 0;
}
return result.first["highestId"] as int? ?? 0;
return result.first["count"] as int? ?? 0;
}
static Future<bool> checkTagIsUsed(

View file

@ -75,11 +75,11 @@ abstract class _Reader {
return db.select("$query;");
}
static Future<ResultSet> _getUsedCoinTagsLastAddedRowId({
static Future<ResultSet> _getUsedCoinTagsCount({
required Database db,
}) async {
const query = """
SELECT MAX(id) AS highestId
SELECT COUNT(*) AS count
FROM SparkUsedCoinTags;
""";

View file

@ -954,7 +954,7 @@ class ElectrumXClient {
Logging.instance.log(
"Finished ElectrumXClient.getSparkUnhashedUsedCoinsTags(startNumber"
"=$startNumber). "
"=$startNumber). # of tags fetched=${tags.length}, "
"Duration=${DateTime.now().difference(start)}",
level: LogLevel.Info,
);