Load transaction metadata from SQLite:

When processing the `tx` command, we will now load both the transaction
and its metadata directly from SQLite.

Previously the `tx` RPC call was querying SQLite for the transaction
and then separately querying the key-value store for the metadata.
This commit is contained in:
Nathan Nichols
2020-07-22 12:24:23 -05:00
committed by Nik Bougalis
parent 8116b569c7
commit 795de3a75a
7 changed files with 147 additions and 114 deletions

View File

@@ -791,16 +791,27 @@ class Ticket_test : public beast::unit_test::suite
boost::optional<std::uint32_t> ticketSeq,
TxType txType) {
error_code_i txErrCode{rpcSUCCESS};
std::shared_ptr<Transaction> const tx{
Transaction::load(txID, env.app(), txErrCode)};
BEAST_EXPECT(txErrCode == rpcSUCCESS);
BEAST_EXPECT(tx->getLedger() == ledgerSeq);
std::shared_ptr<STTx const> const& sttx{tx->getSTransaction()};
BEAST_EXPECT((*sttx)[sfSequence] == txSeq);
if (ticketSeq)
BEAST_EXPECT((*sttx)[sfTicketSequence] == *ticketSeq);
BEAST_EXPECT((*sttx)[sfTransactionType] == txType);
using TxPair = std::
pair<std::shared_ptr<Transaction>, std::shared_ptr<TxMeta>>;
std::variant<TxPair, TxSearched> maybeTx =
Transaction::load(txID, env.app(), txErrCode);
BEAST_EXPECT(txErrCode == rpcSUCCESS);
if (auto txPtr = std::get_if<TxPair>(&maybeTx))
{
std::shared_ptr<Transaction>& tx = txPtr->first;
BEAST_EXPECT(tx->getLedger() == ledgerSeq);
std::shared_ptr<STTx const> const& sttx = tx->getSTransaction();
BEAST_EXPECT((*sttx)[sfSequence] == txSeq);
if (ticketSeq)
BEAST_EXPECT((*sttx)[sfTicketSequence] == *ticketSeq);
BEAST_EXPECT((*sttx)[sfTransactionType] == txType);
}
else
{
fail("Expected transaction was not found");
}
};
// txID ledgerSeq txSeq ticketSeq txType