Skip to content

Commit 6041be2

Browse files
committed
typedef
1 parent c3dcf89 commit 6041be2

10 files changed

+27
-25
lines changed

src/bucket/BucketSnapshotManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ BucketSnapshotManager::BucketSnapshotManager(
5252
}
5353
}
5454

55-
std::shared_ptr<SearchableLiveBucketListSnapshot const>
55+
SearchableSnapshotConstPtr
5656
BucketSnapshotManager::copySearchableLiveBucketListSnapshot() const
5757
{
5858
std::map<uint32_t, SnapshotPtrT<LiveBucket>> historicalSnapshots;
@@ -118,7 +118,7 @@ BucketSnapshotManager::recordBulkLoadMetrics(std::string const& label,
118118

119119
void
120120
BucketSnapshotManager::maybeCopySearchableBucketListSnapshot(
121-
std::shared_ptr<SearchableLiveBucketListSnapshot const>& snapshot)
121+
SearchableSnapshotConstPtr& snapshot)
122122
{
123123
// The canonical snapshot held by the BucketSnapshotManager is not being
124124
// modified. Rather, a thread is checking it's copy against the canonical

src/bucket/BucketSnapshotManager.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class SearchableHotArchiveBucketListSnapshot;
3232

3333
template <class BucketT>
3434
using SnapshotPtrT = std::unique_ptr<BucketListSnapshot<BucketT> const>;
35+
using SearchableSnapshotConstPtr =
36+
std::shared_ptr<SearchableLiveBucketListSnapshot const>;
3537

3638
// This class serves as the boundary between non-threadsafe singleton classes
3739
// (BucketManager, BucketList, Metrics, etc) and threadsafe, parallel BucketList
@@ -80,14 +82,13 @@ class BucketSnapshotManager : NonMovableOrCopyable
8082
SnapshotPtrT<HotArchiveBucket>&& hotArchiveSnapshot,
8183
uint32_t numHistoricalLedgers);
8284

83-
std::shared_ptr<SearchableLiveBucketListSnapshot const>
84-
copySearchableLiveBucketListSnapshot() const;
85+
SearchableSnapshotConstPtr copySearchableLiveBucketListSnapshot() const;
8586

8687
std::shared_ptr<SearchableHotArchiveBucketListSnapshot const>
8788
copySearchableHotArchiveBucketListSnapshot() const;
8889

89-
void maybeCopySearchableBucketListSnapshot(
90-
std::shared_ptr<SearchableLiveBucketListSnapshot const>& snapshot);
90+
void
91+
maybeCopySearchableBucketListSnapshot(SearchableSnapshotConstPtr& snapshot);
9192

9293
// All metric recording functions must only be called by the main thread
9394
void startPointLoadTimer() const;

src/bucket/SearchableBucketList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class SearchableLiveBucketListSnapshot
3636
std::shared_ptr<EvictionStatistics> stats,
3737
StateArchivalSettings const& sas) const;
3838

39-
friend std::shared_ptr<SearchableLiveBucketListSnapshot const>
39+
friend SearchableSnapshotConstPtr
4040
BucketSnapshotManager::copySearchableLiveBucketListSnapshot() const;
4141
};
4242

src/ledger/LedgerManager.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ class LedgerManager
9797
getLastClosedLedgerHeader() const = 0;
9898

9999
// Get bucketlist snapshot
100-
virtual std::shared_ptr<SearchableLiveBucketListSnapshot const>
101-
getCurrentLedgerStateSnaphot() = 0;
100+
virtual SearchableSnapshotConstPtr getCurrentLedgerStateSnaphot() = 0;
102101

103102
// return the HAS that corresponds to the last closed ledger as persisted in
104103
// the database

src/ledger/LedgerManagerImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ LedgerManagerImpl::maybeResetLedgerCloseMetaDebugStream(uint32_t ledgerSeq)
12611261
}
12621262
}
12631263

1264-
std::shared_ptr<SearchableLiveBucketListSnapshot const>
1264+
SearchableSnapshotConstPtr
12651265
LedgerManagerImpl::getCurrentLedgerStateSnaphot()
12661266
{
12671267
if (!mReadOnlyLedgerStateSnapshot)

src/ledger/LedgerManagerImpl.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ class LedgerManagerImpl : public LedgerManager
5151
private:
5252
LedgerHeaderHistoryEntry mLastClosedLedger;
5353

54-
// TODO: better comment
5554
// Read-only Soroban network configuration, accessible by main thread only.
55+
// This config has to match the read-only ledger state snapshot managed by
56+
// LedgerManager. Today this is only accessed by the main thread, but it can
57+
// be used by multiple threads as long snapshot consistency
58+
// requirement is preserved (though synchronization should be added in this
59+
// case)
5660
std::shared_ptr<SorobanNetworkConfig const> mSorobanNetworkConfigReadOnly;
5761

5862
// Latest Soroban config during apply (should not be used outside of
59-
// application, as it may be in half-valid state).
63+
// application, as it may be in half-valid state). Note that access to this
64+
// variable is not synchronized, since it should only be used by one thread
65+
// (main or ledger close).
6066
std::shared_ptr<SorobanNetworkConfig> mSorobanNetworkConfigForApply;
6167

6268
SorobanMetrics mSorobanMetrics;
@@ -75,8 +81,7 @@ class LedgerManagerImpl : public LedgerManager
7581
medida::Timer& mMetaStreamWriteTime;
7682
VirtualClock::time_point mLastClose;
7783
bool mRebuildInMemoryState{false};
78-
std::shared_ptr<SearchableLiveBucketListSnapshot const>
79-
mReadOnlyLedgerStateSnapshot;
84+
SearchableSnapshotConstPtr mReadOnlyLedgerStateSnapshot;
8085

8186
std::unique_ptr<VirtualClock::time_point> mStartCatchup;
8287
medida::Timer& mCatchupDuration;
@@ -211,7 +216,6 @@ class LedgerManagerImpl : public LedgerManager
211216
void maybeResetLedgerCloseMetaDebugStream(uint32_t ledgerSeq);
212217

213218
SorobanMetrics& getSorobanMetrics() override;
214-
std::shared_ptr<SearchableLiveBucketListSnapshot const>
215-
getCurrentLedgerStateSnaphot() override;
219+
SearchableSnapshotConstPtr getCurrentLedgerStateSnaphot() override;
216220
};
217221
}

src/ledger/LedgerStateSnapshot.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ LedgerTxnReadOnly::executeWithMaybeInnerSnapshot(
163163
return f(lsg);
164164
}
165165

166-
BucketSnapshotState::BucketSnapshotState(
167-
std::shared_ptr<SearchableLiveBucketListSnapshot const> snapshot)
166+
BucketSnapshotState::BucketSnapshotState(SearchableSnapshotConstPtr snapshot)
168167
: mSnapshot(snapshot)
169168
, mLedgerHeader(LedgerHeaderWrapper(
170169
std::make_shared<LedgerHeader>(mSnapshot->getLedgerHeader())))

src/ledger/LedgerStateSnapshot.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,14 @@ class LedgerTxnReadOnly : public AbstractLedgerStateSnapshot
106106
// A concrete implementation of read-only BucketList snapshot wrapper
107107
class BucketSnapshotState : public AbstractLedgerStateSnapshot
108108
{
109-
std::shared_ptr<SearchableLiveBucketListSnapshot const> const mSnapshot;
109+
SearchableSnapshotConstPtr const mSnapshot;
110110
// Store a copy of the header from mSnapshot. This is needed for
111111
// validation flow where for certain validation scenarios the header needs
112112
// to be modified
113113
LedgerHeaderWrapper mLedgerHeader;
114114

115115
public:
116-
BucketSnapshotState(
117-
std::shared_ptr<SearchableLiveBucketListSnapshot const> snapshot);
116+
BucketSnapshotState(SearchableSnapshotConstPtr snapshot);
118117
~BucketSnapshotState() override;
119118

120119
LedgerHeaderWrapper getLedgerHeader() const override;

src/ledger/LedgerTxnImpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// under the Apache License, Version 2.0. See the COPYING file at the root
55
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
66

7+
#include "bucket/BucketSnapshotManager.h"
78
#include "database/Database.h"
89
#include "ledger/LedgerTxn.h"
910
#include "util/RandomEvictionCache.h"
@@ -616,8 +617,7 @@ class LedgerTxnRoot::Impl
616617
mutable BestOffers mBestOffers;
617618
mutable uint64_t mPrefetchHits{0};
618619
mutable uint64_t mPrefetchMisses{0};
619-
mutable std::shared_ptr<SearchableLiveBucketListSnapshot const>
620-
mSearchableBucketListSnapshot;
620+
mutable SearchableSnapshotConstPtr mSearchableBucketListSnapshot;
621621

622622
size_t mBulkLoadBatchSize;
623623
std::unique_ptr<soci::transaction> mTransaction;

src/main/QueryServer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "lib/httpthreaded/server.hpp"
88

9+
#include "bucket/BucketSnapshotManager.h"
910
#include <functional>
1011
#include <memory>
1112
#include <string>
@@ -25,8 +26,7 @@ class QueryServer
2526

2627
httpThreaded::server::server mServer;
2728

28-
std::unordered_map<std::thread::id,
29-
std::shared_ptr<SearchableLiveBucketListSnapshot const>>
29+
std::unordered_map<std::thread::id, SearchableSnapshotConstPtr>
3030
mBucketListSnapshots;
3131

3232
BucketSnapshotManager& mBucketSnapshotManager;

0 commit comments

Comments
 (0)