-
Notifications
You must be signed in to change notification settings - Fork 6
feat/#76 implement roll back to #130
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #130 +/- ##
==========================================
+ Coverage 95.64% 95.68% +0.04%
==========================================
Files 72 72
Lines 1217 1252 +35
Branches 155 162 +7
==========================================
+ Hits 1164 1198 +34
- Misses 53 54 +1
Continue to review full report at Codecov.
|
f136f49 to
5c80bc5
Compare
|
Let's implement this feature without introduce breaking change in the protected async rollbackTo(blockNumber: number): Promise<void> {
this.log.debug('-- roll back to block number:', blockNumber);
// - [ ] TODO alter current index state
// - [ ] TODO revert all change from blockNumber to current blockNumber
// Aloxide Updater will create a snapshot of data when applying a last irreversible block
// doing so we can quickly roll back to the last irreversible block state
// This is only applied to Aloxide data
}
public async handleBlock(nextBlock: NextBlock, isReplay: boolean): Promise<number | null> {
try {
return super.handleBlock(nextBlock, isReplay);
} catch (e) {
if (e instanceof MismatchedBlockHashError) {
// roll back to the last irreversible blocks
// - [ ] TODO explain why it must be the last irreversible block
// - [ ] what hapen if the rollbackTo took too long to execute
await this.rollbackTo(this.lastIrreversibleBlockNumber);
return this.lastIrreversibleBlockNumber + 1;
}
throw e;
}
} |
b7c2de1 to
76508d8
Compare
|
@manh-vv please help me review again!. |
manh-vv
left a comment
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.
Please have a direct talk if you have any questions about my comments.
76508d8 to
1b0086f
Compare
manh-vv
left a comment
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.
LGTM
Require lecle/demux-js#2 to be merged first