Skip to content

Commit

Permalink
fix: don't force fetch message count for non-existent fids (#1653)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayprabhu authored Feb 5, 2024
1 parent 618e6fa commit d3cd9c9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/hubble/src/storage/stores/storageCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ export class StorageCache {
log.info({ timeTakenMs: Date.now() - start, totalFids }, "storage cache prepopulation finished");
}

async getMessageCount(fid: number, set: UserMessagePostfix): HubAsyncResult<number> {
async getMessageCount(fid: number, set: UserMessagePostfix, forceFetch = true): HubAsyncResult<number> {
const key = makeKey(fid, set);
if (this._counts.get(key) === undefined) {
if (this._counts.get(key) === undefined && forceFetch) {
let total = 0;
await this._db.forEachIteratorByPrefix(
makeMessagePrimaryKey(fid, set),
Expand Down
2 changes: 1 addition & 1 deletion apps/hubble/src/storage/stores/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export abstract class Store<TAdd extends Message, TRemove extends Message> {
async pruneMessages(fid: number): HubAsyncResult<number[]> {
const commits: number[] = [];

const cachedCount = await this._eventHandler.getCacheMessageCount(fid, this._postfix);
const cachedCount = await this._eventHandler.getCacheMessageCount(fid, this._postfix, false);
const units = await this._eventHandler.getCurrentStorageUnitsForFid(fid);

if (units.isErr()) {
Expand Down
4 changes: 2 additions & 2 deletions apps/hubble/src/storage/stores/storeEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ class StoreEventHandler extends TypedEmitter<StoreEvents> {
});
}

async getCacheMessageCount(fid: number, set: UserMessagePostfix): HubAsyncResult<number> {
return this._storageCache.getMessageCount(fid, set);
async getCacheMessageCount(fid: number, set: UserMessagePostfix, forceFetch = true): HubAsyncResult<number> {
return this._storageCache.getMessageCount(fid, set, forceFetch);
}

async getEarliestTsHash(fid: number, set: UserMessagePostfix): HubAsyncResult<Uint8Array | undefined> {
Expand Down

0 comments on commit d3cd9c9

Please sign in to comment.