-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup apply and validation flows (#4471)
Part of #4318 - main change is to stop passing around Application during validation and application flows, and use AppConnector instead, which is forced to either assert main thread or implement thread-safe methods Resolves #3800 - note that READ_ONLY_WITHOUT_SQL_TXN LedgerTxn mode should go away completely once we switch to mandatory BucketListDB. It looks like we were using RO LedgerTxn during apply scenarios, which I think is not legal? Either way, all READ_ONLY_WITHOUT_SQL_TXN usages except for the legacy one in LedgerSnapshot have been removed now. Note that the second commit has a huge diff but is a no-op, as it's basically a find and replace for `Application -> AppConnector`
- Loading branch information
Showing
104 changed files
with
889 additions
and
651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include "main/AppConnector.h" | ||
#include "herder/Herder.h" | ||
#include "invariant/InvariantManager.h" | ||
#include "ledger/LedgerManager.h" | ||
#include "ledger/LedgerTxn.h" | ||
#include "main/Application.h" | ||
#include "overlay/BanManager.h" | ||
#include "overlay/OverlayManager.h" | ||
#include "overlay/OverlayMetrics.h" | ||
#include "util/Timer.h" | ||
|
||
namespace stellar | ||
{ | ||
|
||
AppConnector::AppConnector(Application& app) | ||
: mApp(app), mConfig(app.getConfig()) | ||
{ | ||
} | ||
|
||
Herder& | ||
AppConnector::getHerder() | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getHerder(); | ||
} | ||
|
||
LedgerManager& | ||
AppConnector::getLedgerManager() | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getLedgerManager(); | ||
} | ||
|
||
OverlayManager& | ||
AppConnector::getOverlayManager() | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getOverlayManager(); | ||
} | ||
|
||
BanManager& | ||
AppConnector::getBanManager() | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getBanManager(); | ||
} | ||
|
||
SorobanNetworkConfig const& | ||
AppConnector::getSorobanNetworkConfig() const | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getLedgerManager().getSorobanNetworkConfig(); | ||
} | ||
|
||
medida::MetricsRegistry& | ||
AppConnector::getMetrics() const | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getMetrics(); | ||
} | ||
|
||
SorobanMetrics& | ||
AppConnector::getSorobanMetrics() const | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getLedgerManager().getSorobanMetrics(); | ||
} | ||
|
||
void | ||
AppConnector::checkOnOperationApply(Operation const& operation, | ||
OperationResult const& opres, | ||
LedgerTxnDelta const& ltxDelta) | ||
{ | ||
releaseAssert(threadIsMain()); | ||
mApp.getInvariantManager().checkOnOperationApply(operation, opres, | ||
ltxDelta); | ||
} | ||
|
||
Hash const& | ||
AppConnector::getNetworkID() const | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getNetworkID(); | ||
} | ||
|
||
void | ||
AppConnector::postOnMainThread(std::function<void()>&& f, std::string&& message, | ||
Scheduler::ActionType type) | ||
{ | ||
mApp.postOnMainThread(std::move(f), std::move(message), type); | ||
} | ||
|
||
void | ||
AppConnector::postOnOverlayThread(std::function<void()>&& f, | ||
std::string const& message) | ||
{ | ||
mApp.postOnOverlayThread(std::move(f), message); | ||
} | ||
|
||
Config const& | ||
AppConnector::getConfig() const | ||
{ | ||
return mConfig; | ||
} | ||
|
||
bool | ||
AppConnector::overlayShuttingDown() const | ||
{ | ||
return mApp.getOverlayManager().isShuttingDown(); | ||
} | ||
|
||
VirtualClock::time_point | ||
AppConnector::now() const | ||
{ | ||
return mApp.getClock().now(); | ||
} | ||
|
||
bool | ||
AppConnector::shouldYield() const | ||
{ | ||
releaseAssert(threadIsMain()); | ||
return mApp.getClock().shouldYield(); | ||
} | ||
|
||
OverlayMetrics& | ||
AppConnector::getOverlayMetrics() | ||
{ | ||
// OverlayMetrics class is thread-safe | ||
return mApp.getOverlayManager().getOverlayMetrics(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.