Skip to content

Commit

Permalink
do not throw error if subql stops
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Apr 6, 2024
1 parent 1007851 commit aa85870
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions packages/eth-providers/src/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1750,37 +1750,12 @@ export abstract class BaseProvider extends AbstractProvider {
return txFromCache;
}

await this._checkSubqlHeight();

const txFromSubql = await this.subql?.getTxReceiptByHash(txHash);
return txFromSubql
? subqlReceiptAdapter(txFromSubql)
: null;
};

// make sure there is no gap between subql and cache
_checkSubqlHeight = async (): Promise<number> => {
if (!this.subql) return;

const maxMissedBlockCount = this.blockCache.cachedBlockHashes.length;
const lastProcessedHeight = await this.subql.getLastProcessedHeight();
const minSubqlHeight = await this.finalizedBlockNumber - maxMissedBlockCount;
if (lastProcessedHeight < minSubqlHeight) {
return logger.throwError(
'subql indexer height is less than the minimum height required',
Logger.errors.SERVER_ERROR,
{
lastProcessedHeight,
minSubqlHeight,
maxMissedBlockCount,
curFinalizedHeight: await this.finalizedBlockNumber,
}
);
}

return lastProcessedHeight;
};

_sanitizeRawFilter = async (rawFilter: LogFilter): Promise<SanitizedLogFilter> => {
const { fromBlock, toBlock, blockHash, address, topics } = rawFilter;
const filter: SanitizedLogFilter = {
Expand Down Expand Up @@ -1819,7 +1794,7 @@ export abstract class BaseProvider extends AbstractProvider {

_getSubqlMissedLogs = async (toBlock: number, filter: SanitizedLogFilter): Promise<Log[]> => {
const targetBlock = Math.min(toBlock, await this.finalizedBlockNumber); // subql upperbound is finalizedBlockNumber
const lastProcessedHeight = await this._checkSubqlHeight();
const lastProcessedHeight = await this.subql.getLastProcessedHeight();
const missedBlockCount = targetBlock - lastProcessedHeight;
if (missedBlockCount <= 0) return [];

Expand Down

0 comments on commit aa85870

Please sign in to comment.