Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
jiqiang90 committed Dec 22, 2023
1 parent e4f1c8f commit 47e64e5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ export abstract class DictionaryServiceV1<DS> extends CoreDictionaryService<DS>
}

getQueryEndBlock(startBlockHeight: number, apiFinalizedHeight: number): number {
return Math.min(startBlockHeight + this.nodeConfig.dictionaryQuerySize, apiFinalizedHeight);
return Math.min(
startBlockHeight + this.nodeConfig.dictionaryQuerySize,
apiFinalizedHeight,
this.metadata.lastProcessedHeight
);
}

protected get client(): ApolloClient<NormalizedCacheObject> {
Expand Down Expand Up @@ -189,7 +193,7 @@ export abstract class DictionaryServiceV1<DS> extends CoreDictionaryService<DS>
}

queryMapValidByHeight(height: number): boolean {
return !!this.queriesMap?.get(height);
return !!this.queriesMap?.get(height)?.length;
}

// Base validation is required, and specific validation for each network should be implemented accordingly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export abstract class DictionaryServiceV2<
abstract getDictionary(startBlock: number, queryEndBlock: number, limit: number): Promise<Dictionary<FB> | undefined>;

queryMapValidByHeight(height: number): boolean {
return !!this.queriesMap?.get(height)?.length;
return !!this.queriesMap?.get(height);
}

dictionaryValidation(metaData?: DictionaryV2Metadata, startBlockHeight?: number): boolean {
Expand Down
9 changes: 2 additions & 7 deletions packages/node-core/src/indexer/fetch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,11 @@ export abstract class BaseFetchService<
// batchBlocks = uniq(batchBlocks.concat(moduloBlocks)).sort((a, b) => a - b);
if (batchBlocks.length === 0) {
// There we're no blocks in this query range, we can set a new height we're up to
await this.blockDispatcher.enqueueBlocks(
[],
dictionary.queryEndBlock
// TODO, query endBlock now should return include->
// Math.min(dictionary.queryEndBlock, dictionary._metadata.lastProcessedHeight)
);
await this.blockDispatcher.enqueueBlocks([], dictionary.queryEndBlock);
} else {
const maxBlockSize = Math.min(batchBlocks.length, this.blockDispatcher.freeSize);
const enqueueBlocks = batchBlocks.slice(0, maxBlockSize);
// await this.enqueueBlocks(enqueueBlocks, latestHeight);
await this.blockDispatcher.enqueueBlocks(enqueueBlocks, latestHeight);
}
continue; // skip nextBlockRange() way
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NETWORK_FAMILY } from '@subql/common';
import { DictionaryVersion, NodeConfig } from '@subql/node-core';
import { DictionaryService } from '@subql/node-core/indexer/dictionary/dictionary.service';
import { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';
import { logger } from 'ethers';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { EthDictionaryServiceV1 } from './v1/eth-dictionary.service.v1';
import { EthDictionaryServiceV2, RawEthFatBlock } from './v2';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const CHAIN_ALIASES_URL =

const logger = getLogger('eth-dictionary v1');

console.log('XXXXX', DictionaryServiceV1);

export function appendDsOptions(
dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],
conditions: DictionaryQueryCondition[],
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/indexer/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const logger = getLogger(`worker #${threadId}`);
async function initWorker(startHeight: number): Promise<void> {
try {
const app = await NestFactory.create(WorkerModule, {
logger: new NestLogger(!!argv.debug), // TIP: If the worker is crashing comment out this line for better logging
// logger: new NestLogger(!!argv.debug), // TIP: If the worker is crashing comment out this line for better logging
});

await app.init();
Expand Down

0 comments on commit 47e64e5

Please sign in to comment.