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

feat(db): optimize calculation services for reward when the node starts #5654

Merged

Conversation

halibobo1205
Copy link
Contributor

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.

@@ -465,6 +469,7 @@ public void init() {
revokingStore.disable();
revokingStore.check();
transactionCache.initCache();
rewardViCalService.init();
Copy link
Contributor

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?

Copy link
Contributor Author

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;
}
Copy link
Contributor

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);
Copy link
Contributor

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();
}

Copy link
Contributor Author

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.

Copy link
Contributor

@xxo1shine xxo1shine Jan 15, 2024

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

@halibobo1205 halibobo1205 merged commit 32e1e15 into tronprotocol:release_v4.7.4 Jan 15, 2024
5 checks passed
@halibobo1205 halibobo1205 added this to the GreatVoyage-v4.7.4 milestone Jan 22, 2024
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.

None yet

4 participants