-
Notifications
You must be signed in to change notification settings - Fork 90
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
Save blocks to db #359
Save blocks to db #359
Conversation
right, maybe my understanding is wrong, if we want to resume from where we last stopped, is it necessary to save every block? If not, I guess we don't need to save them |
We want to save all the new blocks. We don't need to save blocks fetched from remote API. Right now it is saving all the blocks including the one fetched from remote API. |
should work like this chain: 1 -> 2 -> 3 -> 4 -> 5 -> head 6 chopsticks start with --resume flag then load head from db |
Made some changes, now only save blocks created by us |
I think with this, we will be able to load chain from db by specifying right block hash. Need a manual test and e2e test to confirm that. |
expect(blockData?.parentHash).toEqual((await block?.parentBlock)?.hash) | ||
expect(JSON.stringify(blockData?.extrinsics)).toEqual(JSON.stringify(await block?.extrinsics)) | ||
expect(JSON.stringify(blockData?.storageDiff)).toEqual(JSON.stringify(await block?.storageDiff())) | ||
const blockData = await chain.db!.getRepository('Block').findOne({ where: { number: chain.head.number } }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check block
and blockData
is not undefined and no need all the !
Maybe do this in a separate PR coz may need to change |
related to #347