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(ckb-indexer)!: wait for the next n blocks #655

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .changeset/eight-pots-invent.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"@ckb-lumos/lumos": minor
---

BREAKING CHANGE: refine the export structure
**BREAKING CHANGE**: refine the export structure
5 changes: 5 additions & 0 deletions .changeset/purple-countries-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ckb-lumos/ckb-indexer": minor
---

**BREAKING CHANGE**: correct the semantic of the `waitForSync`
4 changes: 2 additions & 2 deletions packages/ckb-indexer/src/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
return new Promise((resolve) => setTimeout(resolve, timeout));
}

async waitForSync(blockDifference = 0): Promise<void> {
async waitForSync(nextNBlocks = 0): Promise<void> {
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) {

Check warning on line 94 in packages/ckb-indexer/src/indexer.ts

View check run for this annotation

Codecov / codecov/patch

packages/ckb-indexer/src/indexer.ts#L94

Added line #L94 was not covered by tests
return;
}
await this.asyncSleep(1000);
Expand Down
Loading