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

Persist ledger #3926

Closed
wants to merge 2 commits into from
Closed

Persist ledger #3926

wants to merge 2 commits into from

Conversation

mtrippled
Copy link
Collaborator

High Level Overview of Change

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

* @return True if the shard store exists
*/
bool
shardStoreExists()
Copy link
Contributor

@miguelportilla miguelportilla Sep 8, 2021

Choose a reason for hiding this comment

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

This function can be const and declared [[nodiscard]].

* @return True if node ledger DB exists.
*/
bool
existsLedger()
{
return !!lgrdb_;
return static_cast<bool>(lgrdb_);
Copy link
Contributor

@miguelportilla miguelportilla Sep 8, 2021

Choose a reason for hiding this comment

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

Likely outside this PR's scope but since you are touching this function, it may be a good idea to make it const and declare [[nodiscard]].

* @return True if node transaction DB exists.
*/
bool
existsTransaction()
{
return !!txdb_;
return static_cast<bool>(txdb_);
Copy link
Contributor

@miguelportilla miguelportilla Sep 8, 2021

Choose a reason for hiding this comment

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

Likely outside this PR's scope but since you are touching this function, it may be a good idea to make it const and declare [[nodiscard]].

if (existsLedger() && existsTransaction())
{
if (!ripple::saveValidatedLedger(
*lgrdb_, *txdb_, app_, ledger, current))
return false;
}

if (auto shardStore = app_.getShardStore())
if (auto shardStore = app_.getShardStore(); shardStore)
Copy link
Contributor

@miguelportilla miguelportilla Sep 8, 2021

Choose a reason for hiding this comment

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

The second condition check is redundant. Should be: if (auto shardStore = app_.getShardStore())

return false;
}
return true;
});
Copy link
Contributor

@miguelportilla miguelportilla Sep 8, 2021

Choose a reason for hiding this comment

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

I don't believe it's necessary to use an info local. Here is a slightly optimized alternate version.

 if (res = ripple::getNewestLedgerInfo(session, j_); res)
     return false;
return true;

iterateLedgerForward(
seqToShardIndex(ledgerFirstIndex),
[&](soci::session& session, std::uint32_t shardIndex) {
if (auto info = ripple::getLimitedOldestLedgerInfo(
Copy link
Contributor

@miguelportilla miguelportilla Sep 8, 2021

Choose a reason for hiding this comment

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

Same comment as above pertaining to info.

std::optional<LedgerInfo> res;
iterateLedgerBack(
{}, [&](soci::session& session, std::uint32_t shardIndex) {
if (auto info = ripple::getLimitedNewestLedgerInfo(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above pertaining to info.

@mtrippled
Copy link
Collaborator Author

@miguelportilla Please only review this commit: 8e5c768

Sorry about this--this commit sits upon another commit that has already been approved but not yet in develop.

Copy link
Contributor

@miguelportilla miguelportilla left a comment

Choose a reason for hiding this comment

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

Option fix you might want to sneak in. The documentation for iterateTransactionBack is incorrect. It states iterateTransactionForward versus iterateTransactionBack

I left a few comments for the first commit, nothing critical. If we decide to postpone those changes now, they can easily be addressed in a future PR.

The second commit LGTM. Thank you for your fixes, Mark!

Copy link
Contributor

@undertome undertome left a comment

Choose a reason for hiding this comment

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

I only reviewed 8e5c768

@mtrippled mtrippled added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Sep 8, 2021
@manojsdoshi manojsdoshi mentioned this pull request Sep 9, 2021
@nbougalis nbougalis mentioned this pull request Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants