[blockchain watcher] skip no txs block (#912)

skip no txs block
This commit is contained in:
Matías Martínez 2023-12-14 17:12:15 -03:00 committed by GitHub
parent 2816cf8bfe
commit 6d8b3c4bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -152,12 +152,23 @@ export class PollSolanaTransactions extends RunPollingJob {
): Promise<solana.Block> {
const blockResult = await this.slotRepository.getBlock(slot, this.cfg.commitment);
if (blockResult.isOk()) {
return Promise.resolve(blockResult.getValue());
const block = blockResult.getValue();
if (block.transactions.length > 0) {
return block;
}
const next = nextSlot(slot);
this.logger.warn(
`[findValidBlock] No transactions found for slot ${slot}, trying next slot ${next}`
);
return this.findValidBlock(next, nextSlot);
}
if (blockResult.getError().skippedSlot() || blockResult.getError().noBlockOrBlockTime()) {
this.logger.warn(`No block found for slot ${slot}, trying next slot ${nextSlot(slot)}`);
return this.findValidBlock(nextSlot(slot), nextSlot);
const next = nextSlot(slot);
this.logger.warn(
`[findValidBlock] No block found for slot ${slot}, trying next slot ${next}`
);
return this.findValidBlock(next, nextSlot);
}
throw blockResult.getError();

View File

@ -24,7 +24,7 @@ export class SnsEventRepository {
async publish(events: LogFoundEvent<any>[]): Promise<SnsPublishResult> {
if (!events.length) {
this.logger.warn("[publish] No events to publish, continuing...");
this.logger.debug("[publish] No events to publish, continuing...");
return {
status: "success",
};