-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathAppConnector.h
More file actions
88 lines (75 loc) · 3.13 KB
/
Copy pathAppConnector.h
File metadata and controls
88 lines (75 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2025 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#pragma once
#include "bucket/BucketUtils.h"
#include "ledger/ImmutableLedgerView.h"
#include "main/Application.h"
#include "main/Config.h"
#include "rust/RustBridge.h"
namespace stellar
{
class RustOverlayManager;
class LedgerManager;
class Herder;
class BanManager;
struct OverlayMetrics;
class SorobanNetworkConfig;
class SorobanMetrics;
class SearchableHotArchiveBucketListSnapshot;
struct LedgerTxnDelta;
// Helper class to isolate access to Application; all function helpers must
// either be called from main or be thread-safe
class AppConnector
{
Application& mApp;
// Copy config for threads to use, and avoid warnings from thread sanitizer
// about accessing mApp
Config const mConfig;
public:
AppConnector(Application& app);
// Methods that can only be called from main thread
Herder& getHerder();
LedgerManager& getLedgerManager();
RustOverlayManager& getOverlayManager();
BanManager& getBanManager();
bool shouldYield() const;
void checkOnOperationApply(Operation const& operation,
OperationResult const& opres,
LedgerTxnDelta const& ltxDelta,
std::vector<ContractEvent> const& events);
Hash const& getNetworkID() const;
// Thread-safe methods
SorobanMetrics& getSorobanMetrics() const;
void postOnMainThread(std::function<void()>&& f, std::string&& message);
void postOnOverlayThread(std::function<void()>&& f,
std::string const& message);
void postOnBackgroundThread(std::function<void()>&& f,
std::string const& jobName);
void postOnEvictionBackgroundThread(std::function<void()>&& f,
std::string const& jobName);
VirtualClock::time_point now() const;
Config const& getConfig() const;
rust::Box<rust_bridge::SorobanModuleCache> getModuleCache();
bool overlayShuttingDown() const;
OverlayMetrics& getOverlayMetrics();
SorobanNetworkConfig const& getLastClosedSorobanNetworkConfig() const;
bool threadIsType(Application::ThreadType type) const;
MetricsRegistry& getMetrics() const;
bool isStopping() const;
ImmutableLedgerView copyImmutableLedgerView();
ApplyLedgerView copyApplyLedgerView();
void maybeUpdateImmutableLedgerView(ImmutableLedgerView& ledgerView);
// Protocol 23 data corruption bug data verifier. This typically is null,
// unless a path to a CSV file containing the corruption data was provided
// in the config at startup.
std::unique_ptr<p23_hot_archive_bug::Protocol23CorruptionDataVerifier>&
getProtocol23CorruptionDataVerifier();
std::unique_ptr<p23_hot_archive_bug::Protocol23CorruptionEventReconciler>&
getProtocol23CorruptionEventReconciler();
#ifdef BUILD_TESTS
// Access the runtime overlay-only mode flag for testing
bool getRunInOverlayOnlyMode() const;
#endif
};
}