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

refactor: dry up the body of the indexing #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tansanDOTeth
Copy link
Contributor

Small QOL improvement

}
const block = blockResult.result;

const runeUpdater = new RuneUpdater(this._network, block, true, this._storage, this._rpc);
Copy link
Contributor Author

@tansanDOTeth tansanDOTeth Jun 18, 2024

Choose a reason for hiding this comment

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

@summraznboi gm

I noticed this reorg parameter isn't being used in the RuneUpdater. Do you have plans for it? If not, I can greatly simplify this function here.

Currently, it will process all the reorg hashes first in the loop here:

for (const blockhash of reorgBlockhashesToIndex) {
await this.asyncProcessBlockHash({ blockhash, reorg: true });
}

However, I don't think the code needs to do this here. Instead, we can just set the block height further back for the latter loop, so it will start processing from the last known synced block height.

Ex, here

let blockheight = Math.max(
Network.getFirstRuneHeight(this._network),
currentStorageBlock ? currentStorageBlock.height + 1 : 0
);
let blockhash = (await this._rpc.getblockhash({ height: blockheight })).result;
while (blockhash !== null) {
await this.asyncProcessBlockHash({ blockhash, reorg: false });
blockheight++;
blockhash = (await this._rpc.getblockhash({ height: blockheight })).result;
}

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you provide some unit tests to ensure no regressions are occurring with this refactor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants