From 949cbe2b4c8aad0ff4f43fdbbc1b0eeef5f21b5b Mon Sep 17 00:00:00 2001 From: JQQQ Date: Mon, 27 Jun 2022 16:39:16 +1200 Subject: [PATCH] fix set block offset --- packages/node/src/indexer/indexer.manager.ts | 3 +-- packages/node/src/indexer/project.service.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/node/src/indexer/indexer.manager.ts b/packages/node/src/indexer/indexer.manager.ts index 26e35577ef..e1a49efcc0 100644 --- a/packages/node/src/indexer/indexer.manager.ts +++ b/packages/node/src/indexer/indexer.manager.ts @@ -56,7 +56,6 @@ const { argv } = getYargsOption(); export class IndexerManager { private api: ApiPromise; private filteredDataSources: SubqlProjectDs[]; - private blockOffset: number; constructor( private storeService: StoreService, @@ -140,7 +139,7 @@ export class IndexerManager { const operationHash = this.storeService.getOperationMerkleRoot(); if ( !u8aEq(operationHash, NULL_MERKEL_ROOT) && - this.blockOffset === undefined + this.projectService.blockOffset === undefined ) { await this.projectService.upsertMetadataBlockOffset( blockHeight - 1, diff --git a/packages/node/src/indexer/project.service.ts b/packages/node/src/indexer/project.service.ts index 4bfe35749a..368c0933b4 100644 --- a/packages/node/src/indexer/project.service.ts +++ b/packages/node/src/indexer/project.service.ts @@ -34,6 +34,7 @@ export class ProjectService { private _schema: string; private metadataRepo: MetadataRepo; private _startHeight: number; + private _blockOffset: number; constructor( private readonly dsProcessorService: DsProcessorService, @@ -53,6 +54,10 @@ export class ProjectService { return this._schema; } + get blockOffset(): number { + return this._blockOffset; + } + get startHeight(): number { return this._startHeight; } @@ -272,7 +277,7 @@ export class ProjectService { await this.metadataRepo.upsert( { key: 'blockOffset', - value: height - 1, + value: height, }, { transaction: tx }, ); @@ -313,9 +318,10 @@ export class ProjectService { return startHeight; } - // FIXME Dedupe with indexermanager + // FIXME Dedupe with indexer manager setBlockOffset(offset: number): void { - logger.info(`set blockoffset to ${offset}`); + logger.info(`set blockOffset to ${offset}`); + this._blockOffset = offset; void this.mmrService .syncFileBaseFromPoi(this.schema, offset) .catch((err) => {