Skip to content

Commit

Permalink
add await for poller and fix bundleCache id
Browse files Browse the repository at this point in the history
  • Loading branch information
bz888 committed Apr 22, 2024
1 parent 0abf7f7 commit da5cb94
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/node/src/utils/kyve/kyve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ export class KyveApi {
): Promise<KyveBundleData[]> {
let bundle = this.getBundleFromCache(height);
if (!bundle) {
const bundleId = await this.getBundleId(height);
const bundleId =
this.cachedBundleDetails.length !== 0
? Math.max(
...this.cachedBundleDetails.map((b) => parseDecimal(b.id)),
) + 1
: await this.getBundleId(height);
bundle = await this.getBundleById(bundleId);
this.addToCachedBundle(bundle);
}
Expand Down Expand Up @@ -272,7 +277,8 @@ export class KyveApi {
return await this.readFromFile(bundleFilePath);
} catch (e: any) {
if (['EEXIST', 'EACCES', 'ENOENT'].includes(e.code)) {
return this.pollUntilReadable(bundleFilePath);
const res = await this.pollUntilReadable(bundleFilePath);
return res;
} else {
throw e;
}
Expand Down

0 comments on commit da5cb94

Please sign in to comment.