-
Notifications
You must be signed in to change notification settings - Fork 989
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
Rewrite state loading path on startup #4166
Conversation
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.
Thanks for this refactor, cleans up the interface a ton! Looks good, just a few nits.
src/ledger/LedgerManager.h
Outdated
@@ -147,8 +147,8 @@ class LedgerManager | |||
virtual void startNewLedger() = 0; | |||
|
|||
// loads the last ledger information from the database | |||
// if handler is set, also loads bucket information and invokes handler. | |||
virtual void loadLastKnownLedger(std::function<void()> handler) = 0; | |||
virtual void loadLastKnownLedger(bool startServices, |
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.
Nit: It would be helpful to add what the parameters mean to this comment. startServices
is pretty clear, ledgerStateReady
is not obvious unless you read the implementation. Maybe slightly rewording to isLedgerStateReady
would help as well.
src/main/ApplicationImpl.cpp
Outdated
} | ||
}; | ||
mLedgerManager->loadLastKnownLedger(loadConfig); | ||
mLedgerManager->loadLastKnownLedger(false, true); |
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.
Nit: add /*startSevices=*/
and /*ledgerStateReady=*/
so we don't have back to back to back raw bools. Applies in a few other places as well.
|
||
while (!done && mVirtualClock.crank(true)) |
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.
Wow this old interface was.... not good
src/ledger/LedgerManagerImpl.cpp
Outdated
|
||
// Step 3. Restore BucketList if we're doing a full core startup | ||
// (startServices=true), OR when using BucketListDB | ||
if (startServices || mApp.getConfig().EXPERIMENTAL_BUCKETLIST_DB) |
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.
We should never check the raw flag, use getConfig().isUsingBucketListDB()
instead.
src/ledger/LedgerManagerImpl.cpp
Outdated
} | ||
handler(); | ||
// Work should only fail during graceful shutdown | ||
releaseAssert(mApp.isStopping()); |
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 this be releaseAssertOrThrow
?
Addressed your feedback. Thanks for reviewing! |
src/ledger/LedgerManagerImpl.cpp
Outdated
} | ||
} | ||
|
||
// Step 3. Restore LedgerManager's internal state |
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.
Step 4?
src/ledger/LedgerManagerImpl.cpp
Outdated
return; | ||
} | ||
|
||
// Step 4. If ledger state is ready and core is in v20, load network configs |
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.
Step 5
src/ledger/LedgerManagerImpl.cpp
Outdated
// In some modes, e.g. in-memory, core's state is rebuilt asynchronously via | ||
// catchup. In this case, we're not able to load the network config at this | ||
// time, and instead must let catchup do it when ready. | ||
if (!isLedgerStateReady) |
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.
I would rather change this to positive condition (i.e. if (isLedgerStateReady) { loadConfig() } else { LOG(...) }
and get rid of the early return (it seems quite easy to forget about it and accidentally skip some logic independent of the config loading).
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.
ok, updated (fixed comments too)
8df0e4f
to
b57d301
Compare
r+ b57d301 |
Resolves #4163