Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix set block offset #1133

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/node/src/indexer/indexer.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const { argv } = getYargsOption();
export class IndexerManager {
private api: ApiPromise;
private filteredDataSources: SubqlProjectDs[];
private blockOffset: number;

constructor(
private storeService: StoreService,
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions packages/node/src/indexer/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class ProjectService {
private _schema: string;
private metadataRepo: MetadataRepo;
private _startHeight: number;
private _blockOffset: number;

constructor(
private readonly dsProcessorService: DsProcessorService,
Expand All @@ -53,6 +54,10 @@ export class ProjectService {
return this._schema;
}

get blockOffset(): number {
return this._blockOffset;
}

get startHeight(): number {
return this._startHeight;
}
Expand Down Expand Up @@ -272,7 +277,7 @@ export class ProjectService {
await this.metadataRepo.upsert(
{
key: 'blockOffset',
value: height - 1,
value: height,
},
{ transaction: tx },
);
Expand Down Expand Up @@ -313,9 +318,10 @@ export class ProjectService {
return startHeight;
}

// FIXME Dedupe with indexermanager
// FIXME Dedupe with indexer manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had event left a comment!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: D

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) => {
Expand Down