-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(db): optimize calculation services for reward when the node starts #5654
feat(db): optimize calculation services for reward when the node starts #5654
Conversation
@@ -465,6 +469,7 @@ public void init() { | |||
revokingStore.disable(); | |||
revokingStore.check(); | |||
transactionCache.initCache(); | |||
rewardViCalService.init(); |
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.
If rewardViCalService
is initialized behind revokingStore.check()
, is the latestBlockNumber
check still necessary?
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.
scenes are synchronized from 0 and never restarted, check is still necessary.
if (ret) { | ||
// checkpoint is flushed to db, we can start rewardViCalService immediately | ||
lastBlockNumber = Long.MAX_VALUE; | ||
} |
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.
There is no need to define this variable ret
.
The style needs to be consistent, lastBlockNumber
-> this.lastBlockNumber
if (ret) { | ||
// checkpoint is flushed to db, we can start rewardViCalService immediately | ||
lastBlockNumber = Long.MAX_VALUE; | ||
} | ||
es.scheduleWithFixedDelay(this::maybeRun, 0, 3, TimeUnit.SECONDS); |
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.
What is the significance of this code in the enableNewRewardAlgorithm function?
if (ret && lastBlockNumber == -1) {
lastBlockNumber = this.getLatestBlockHeaderNumber();
}
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.
For the block-catching case, record the block for which NewRewardAlgorithm is in effect, and wait for the block to be flushed before data computation to ensure data consistency.
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.
This function getLatestBlockHeaderNumber
obtains the data of the underlying database, right?
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.
Yes.
We can start working on computational tasks immediately without waiting for a minimum of one block to synchronize if the new reward algorithm is already in effect when the node starts.