Skip to content

Commit

Permalink
added more logs to tx fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
DZariusz committed Nov 4, 2024
1 parent a221ff1 commit e17a00b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

## [5.12.4] - 2024-11-04
### Added
- added more logs to tx fetcher

## [5.12.3] - 2024-11-03
### Added
- added more logs to tx fetcher
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanctuary",
"version": "5.12.3",
"version": "5.12.4",
"repository": {
"type": "git",
"url": "git+https://github.com/umbrella-network/sanctuary.git"
Expand Down
17 changes: 9 additions & 8 deletions src/services/on-chain-stats/OnChainTxFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export class OnChainTxFetcher {
const ranges = CreateBatchRanges.apply(rangeFrom, rangeTo, blockchainScanner.settings.fetchBlocksBatchSize);
const timeStart = Date.now();

const feedsMap = await this.umbrellaFeedsMap(chainId);
const allFeedsContracts = await this.umbrellaFeedsMap(chainId);

this.logger.debug(`[OnChainTxFetcher][${chainId}] feedsMap: ${feedsMap.keys()}`);
this.logger.debug(`[OnChainTxFetcher][${chainId}] allFeedsContracts.size: ${allFeedsContracts.size}`);

this.logger.info(
`[OnChainTxFetcher][${chainId}] blocks to sync: ${rangeTo - rangeFrom} blocks, starting from ${rangeFrom}`
Expand All @@ -74,7 +74,8 @@ export class OnChainTxFetcher {

const fetchedBlocks = await this.updateTxRepository.getBlocks(chainId, from, to);
const { txs, lastBlockBeforeError } = await this.txsFetcher.call(chainId, from, to, fetchedBlocks);
const filteredTx = this.onlyUmbrellaFeedsTx(txs, feedsMap);
const filteredTx = this.onlyUmbrellaFeedsTx(txs, allFeedsContracts);
this.logger.debug(`[OnChainTxFetcher][${chainId}] filteredTx: ${filteredTx.length} of ${txs.length}`);

gotError = lastBlockBeforeError !== undefined;
const checkpointBlock = lastBlockBeforeError || to;
Expand Down Expand Up @@ -114,21 +115,21 @@ export class OnChainTxFetcher {
}
}

private onlyUmbrellaFeedsTx(txs: TransactionResponse[], feedsAddresses: Map<string, boolean>): TransactionResponse[] {
private onlyUmbrellaFeedsTx(txs: TransactionResponse[], feedsAddresses: Set<string>): TransactionResponse[] {
return txs.filter((tx) => {
return !!tx.to && feedsAddresses.has(tx.to.toLowerCase());
});
}

private async umbrellaFeedsMap(chainId: ChainsIds): Promise<Map<string, boolean>> {
const map = new Map<string, boolean>();
private async umbrellaFeedsMap(chainId: ChainsIds): Promise<Set<string>> {
const set = new Set<string>();
const umbrellaFeeds = await this.contractRepository.getAllContracts(chainId, UMBRELLA_FEEDS_NAME);

umbrellaFeeds.forEach((uf) => {
map.set(uf.address.toLowerCase(), true);
set.add(uf.address.toLowerCase());
});

return map;
return set;
}

private blockFrom(chainId: ChainsIds, lastSavedBlock: number | undefined): number {
Expand Down

0 comments on commit e17a00b

Please sign in to comment.