From 58527e10b381953fb6e5860098f58b10eb92a1ed Mon Sep 17 00:00:00 2001 From: homura Date: Wed, 20 Mar 2024 11:21:14 +0800 Subject: [PATCH 1/2] fix(ckb-indexer)!: wait for the next n blocks --- packages/ckb-indexer/src/indexer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ckb-indexer/src/indexer.ts b/packages/ckb-indexer/src/indexer.ts index 35663c6ec..db25a8db3 100644 --- a/packages/ckb-indexer/src/indexer.ts +++ b/packages/ckb-indexer/src/indexer.ts @@ -84,14 +84,14 @@ export class CkbIndexer implements CellProvider, TerminableCellFetcher { return new Promise((resolve) => setTimeout(resolve, timeout)); } - async waitForSync(blockDifference = 0): Promise { + async waitForSync(nextNBlocks = 0): Promise { const rpcTipNumber = parseInt( (await this.getCkbRpc().getTipHeader()).number, 16 ); while (true) { const indexerTipNumber = parseInt((await this.tip()).blockNumber, 16); - if (indexerTipNumber + blockDifference >= rpcTipNumber) { + if (indexerTipNumber - nextNBlocks >= rpcTipNumber) { return; } await this.asyncSleep(1000); From 6564de27391d1a7b056708d9adc1f2a317edd6ea Mon Sep 17 00:00:00 2001 From: homura Date: Wed, 20 Mar 2024 11:25:36 +0800 Subject: [PATCH 2/2] docs: changeset --- .changeset/eight-pots-invent.md | 2 +- .changeset/purple-countries-fetch.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/purple-countries-fetch.md diff --git a/.changeset/eight-pots-invent.md b/.changeset/eight-pots-invent.md index 285c5ff97..e46412a86 100644 --- a/.changeset/eight-pots-invent.md +++ b/.changeset/eight-pots-invent.md @@ -2,4 +2,4 @@ "@ckb-lumos/lumos": minor --- -BREAKING CHANGE: refine the export structure +**BREAKING CHANGE**: refine the export structure diff --git a/.changeset/purple-countries-fetch.md b/.changeset/purple-countries-fetch.md new file mode 100644 index 000000000..526c813ef --- /dev/null +++ b/.changeset/purple-countries-fetch.md @@ -0,0 +1,5 @@ +--- +"@ckb-lumos/ckb-indexer": minor +--- + +**BREAKING CHANGE**: correct the semantic of the `waitForSync`