Skip to content

Commit 07be739

Browse files
Cleanup DB dead code (#5143)
2 parents c47b371 + 77d4051 commit 07be739

File tree

13 files changed

+32
-509
lines changed

13 files changed

+32
-509
lines changed

Builds/VisualStudio/stellar-core.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ exit /b 0
748748
<ClCompile Include="..\..\src\transactions\TransactionFrame.cpp" />
749749
<ClCompile Include="..\..\src\transactions\TransactionFrameBase.cpp" />
750750
<ClCompile Include="..\..\src\transactions\TransactionMeta.cpp" />
751-
<ClCompile Include="..\..\src\transactions\TransactionSQL.cpp" />
752751
<ClCompile Include="..\..\src\transactions\TransactionUtils.cpp" />
753752
<ClCompile Include="..\..\src\transactions\TrustFlagsOpFrameBase.cpp" />
754753
<ClCompile Include="..\..\src\util\Backtrace.cpp" />
@@ -1166,7 +1165,6 @@ exit /b 0
11661165
<ClInclude Include="..\..\src\transactions\TransactionFrame.h" />
11671166
<ClInclude Include="..\..\src\transactions\TransactionFrameBase.h" />
11681167
<ClInclude Include="..\..\src\transactions\TransactionMeta.h" />
1169-
<ClInclude Include="..\..\src\transactions\TransactionSQL.h" />
11701168
<ClInclude Include="..\..\src\transactions\TransactionUtils.h" />
11711169
<ClInclude Include="..\..\src\transactions\TrustFlagsOpFrameBase.h" />
11721170
<ClInclude Include="..\..\src\util\Backtrace.h" />

Builds/VisualStudio/stellar-core.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,9 +1239,6 @@
12391239
<ClCompile Include="..\..\src\transactions\TransactionMeta.cpp">
12401240
<Filter>transactions</Filter>
12411241
</ClCompile>
1242-
<ClCompile Include="..\..\src\transactions\TransactionSQL.cpp">
1243-
<Filter>transactions</Filter>
1244-
</ClCompile>
12451242
<ClCompile Include="..\..\src\transactions\TransactionUtils.cpp">
12461243
<Filter>transactions</Filter>
12471244
</ClCompile>
@@ -2343,9 +2340,6 @@
23432340
<ClInclude Include="..\..\src\transactions\TransactionMeta.h">
23442341
<Filter>transactions</Filter>
23452342
</ClInclude>
2346-
<ClInclude Include="..\..\src\transactions\TransactionSQL.h">
2347-
<Filter>transactions</Filter>
2348-
</ClInclude>
23492343
<ClInclude Include="..\..\src\transactions\TransactionUtils.h">
23502344
<Filter>transactions</Filter>
23512345
</ClInclude>

src/database/Database.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "overlay/BanManager.h"
3030
#include "overlay/OverlayManager.h"
3131
#include "overlay/PeerManager.h"
32-
#include "transactions/TransactionSQL.h"
3332

3433
#include "medida/counter.h"
3534
#include "medida/timer.h"

src/history/HistoryManagerImpl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "main/Application.h"
3030
#include "main/Config.h"
3131
#include "medida/meter.h"
32-
#include "transactions/TransactionSQL.h"
3332
#include "util/BufferedAsioCerealOutputArchive.h"
3433
#include "util/Fs.h"
3534
#include "util/GlobalChecks.h"

src/history/StateSnapshot.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "history/HistoryManager.h"
1515
#include "main/Application.h"
1616
#include "main/Config.h"
17-
#include "transactions/TransactionSQL.h"
1817
#include "util/Fs.h"
1918
#include "util/GlobalChecks.h"
2019
#include "util/Logging.h"

src/history/test/HistoryTests.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,12 +1700,6 @@ TEST_CASE("persist publish queue", "[history][publish][acceptance]")
17001700
LedgerManager::GENESIS_LEDGER_SEQ, publishedCount, out);
17011701
REQUIRE(scp == 0);
17021702

1703-
CheckpointBuilder cb(*app1);
1704-
auto headers = LedgerHeaderUtils::copyToStream(
1705-
app1->getDatabase().getRawSession(),
1706-
LedgerManager::GENESIS_LEDGER_SEQ, publishedCount, cb);
1707-
REQUIRE(headers == 0);
1708-
17091703
// We should have either an empty publish queue or a
17101704
// ledger sometime after the 5th checkpoint (ledger 5 * 8 - 1 = 39)
17111705
auto minLedger =

src/ledger/LedgerHeaderUtils.cpp

Lines changed: 32 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
#include "crypto/SHA.h"
88
#include "database/Database.h"
99
#include "database/DatabaseUtils.h"
10-
#include "history/CheckpointBuilder.h"
1110
#include "util/Decoder.h"
12-
#include "util/GlobalChecks.h"
13-
#include "util/Logging.h"
14-
#include "util/XDRStream.h"
1511
#include "util/types.h"
1612
#include "xdrpp/marshal.h"
1713

@@ -22,16 +18,10 @@
2218
namespace stellar
2319
{
2420

25-
namespace LedgerHeaderUtils
26-
{
27-
28-
uint32_t
29-
getFlags(LedgerHeader const& lh)
21+
namespace
3022
{
31-
return lh.ext.v() == 1 ? lh.ext.v1().flags : 0;
32-
}
3323

34-
bool
24+
static bool
3525
isValid(LedgerHeader const& lh)
3626
{
3727
bool res = (lh.ledgerSeq <= INT32_MAX);
@@ -42,6 +32,36 @@ isValid(LedgerHeader const& lh)
4232
return res;
4333
}
4434

35+
static LedgerHeader
36+
decodeFromData(std::string const& data)
37+
{
38+
ZoneScoped;
39+
LedgerHeader lh;
40+
std::vector<uint8_t> decoded;
41+
decoder::decode_b64(data, decoded);
42+
43+
xdr::xdr_get g(&decoded.front(), &decoded.back() + 1);
44+
xdr::xdr_argpack_archive(g, lh);
45+
g.done();
46+
47+
if (!isValid(lh))
48+
{
49+
throw std::runtime_error("invalid ledger header (load)");
50+
}
51+
return lh;
52+
}
53+
54+
} // anonymous namespace
55+
56+
namespace LedgerHeaderUtils
57+
{
58+
59+
uint32_t
60+
getFlags(LedgerHeader const& lh)
61+
{
62+
return lh.ext.v() == 1 ? lh.ext.v1().flags : 0;
63+
}
64+
4565
void
4666
storeInDatabase(Database& db, LedgerHeader const& header, SessionWrapper& sess)
4767
{
@@ -84,25 +104,6 @@ storeInDatabase(Database& db, LedgerHeader const& header, SessionWrapper& sess)
84104
}
85105
}
86106

87-
LedgerHeader
88-
decodeFromData(std::string const& data)
89-
{
90-
ZoneScoped;
91-
LedgerHeader lh;
92-
std::vector<uint8_t> decoded;
93-
decoder::decode_b64(data, decoded);
94-
95-
xdr::xdr_get g(&decoded.front(), &decoded.back() + 1);
96-
xdr::xdr_argpack_archive(g, lh);
97-
g.done();
98-
99-
if (!isValid(lh))
100-
{
101-
throw std::runtime_error("invalid ledger header (load)");
102-
}
103-
return lh;
104-
}
105-
106107
std::shared_ptr<LedgerHeader>
107108
loadByHash(Database& db, Hash const& hash)
108109
{
@@ -140,55 +141,6 @@ loadByHash(Database& db, Hash const& hash)
140141
return lhPtr;
141142
}
142143

143-
uint32_t
144-
loadMaxLedgerSeq(Database& db)
145-
{
146-
ZoneScoped;
147-
uint32_t seq = 0;
148-
soci::indicator maxIndicator;
149-
auto prep = db.getPreparedStatement(
150-
"SELECT MAX(ledgerseq) FROM ledgerheaders", db.getSession());
151-
auto& st = prep.statement();
152-
st.exchange(soci::into(seq, maxIndicator));
153-
st.define_and_bind();
154-
st.execute(true);
155-
if (maxIndicator == soci::indicator::i_ok)
156-
{
157-
return seq;
158-
}
159-
return 0;
160-
}
161-
162-
std::shared_ptr<LedgerHeader>
163-
loadBySequence(Database& db, soci::session& sess, uint32_t seq)
164-
{
165-
ZoneScoped;
166-
std::shared_ptr<LedgerHeader> lhPtr;
167-
168-
std::string headerEncoded;
169-
{
170-
ZoneNamedN(selectLedgerHeadersZone, "select ledgerheaders", true);
171-
sess << "SELECT data FROM ledgerheaders "
172-
"WHERE ledgerseq = :s",
173-
soci::into(headerEncoded), soci::use(seq);
174-
}
175-
if (sess.got_data())
176-
{
177-
auto lh = decodeFromData(headerEncoded);
178-
lhPtr = std::make_shared<LedgerHeader>(lh);
179-
180-
if (lh.ledgerSeq != seq)
181-
{
182-
throw std::runtime_error(fmt::format(
183-
FMT_STRING("Wrong sequence number in ledger header database: "
184-
"loaded ledger {:d} contains {:d}"),
185-
seq, lh.ledgerSeq));
186-
}
187-
}
188-
189-
return lhPtr;
190-
}
191-
192144
void
193145
deleteOldEntries(soci::session& sess, uint32_t ledgerSeq, uint32_t count)
194146
{
@@ -197,38 +149,6 @@ deleteOldEntries(soci::session& sess, uint32_t ledgerSeq, uint32_t count)
197149
"ledgerheaders", "ledgerseq");
198150
}
199151

200-
size_t
201-
copyToStream(soci::session& sess, uint32_t ledgerSeq, uint32_t ledgerCount,
202-
CheckpointBuilder& checkpointBuilder)
203-
{
204-
ZoneNamedN(selectLedgerHeadersZone, "select ledgerheaders history", true);
205-
uint32_t begin = ledgerSeq, end = ledgerSeq + ledgerCount;
206-
releaseAssert(begin <= end);
207-
208-
std::string headerEncoded;
209-
210-
soci::statement st =
211-
(sess.prepare << "SELECT data FROM ledgerheaders "
212-
"WHERE ledgerseq >= :begin AND ledgerseq < :end ORDER "
213-
"BY ledgerseq ASC",
214-
soci::into(headerEncoded), soci::use(begin), soci::use(end));
215-
216-
size_t n = 0;
217-
st.execute(true);
218-
while (st.got_data())
219-
{
220-
LedgerHeaderHistoryEntry lhe;
221-
lhe.header = decodeFromData(headerEncoded);
222-
lhe.hash = xdrSha256(lhe.header);
223-
CLOG_DEBUG(Ledger, "Streaming ledger-header {}", lhe.header.ledgerSeq);
224-
checkpointBuilder.appendLedgerHeader(lhe.header,
225-
/* skipStartupCheck */ true);
226-
++n;
227-
st.fetch();
228-
}
229-
return n;
230-
}
231-
232152
void
233153
maybeDropAndCreateNew(Database& db)
234154
{

src/ledger/LedgerHeaderUtils.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,19 @@
99

1010
namespace stellar
1111
{
12-
class CheckpointBuilder;
1312

1413
namespace LedgerHeaderUtils
1514
{
1615

1716
uint32_t getFlags(LedgerHeader const& lh);
1817

19-
bool isValid(LedgerHeader const& lh);
20-
2118
void storeInDatabase(Database& db, LedgerHeader const& header,
2219
SessionWrapper& sess);
2320

24-
LedgerHeader decodeFromData(std::string const& data);
25-
2621
std::shared_ptr<LedgerHeader> loadByHash(Database& db, Hash const& hash);
2722

28-
std::shared_ptr<LedgerHeader> loadBySequence(Database& db, soci::session& sess,
29-
uint32_t seq);
30-
31-
uint32_t loadMaxLedgerSeq(Database& db);
32-
3323
void deleteOldEntries(soci::session& sess, uint32_t ledgerSeq, uint32_t count);
3424

35-
size_t copyToStream(soci::session& sess, uint32_t ledgerSeq,
36-
uint32_t ledgerCount, CheckpointBuilder& checkpointBuilder);
37-
3825
void maybeDropAndCreateNew(Database& db);
3926
}
4027
}

src/ledger/LedgerManagerImpl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "transactions/ParallelApplyUtils.h"
4141
#include "transactions/TransactionFrameBase.h"
4242
#include "transactions/TransactionMeta.h"
43-
#include "transactions/TransactionSQL.h"
4443
#include "transactions/TransactionUtils.h"
4544
#include "util/DebugMetaUtils.h"
4645
#include "util/Fs.h"

src/simulation/LoadGenerator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "test/TxTests.h"
1313
#include "transactions/MutableTransactionResult.h"
1414
#include "transactions/TransactionBridge.h"
15-
#include "transactions/TransactionSQL.h"
1615
#include "transactions/TransactionUtils.h"
1716
#include "transactions/test/SorobanTxTestUtils.h"
1817
#include "util/Logging.h"

0 commit comments

Comments
 (0)