rippled
Loading...
Searching...
No Matches
AccountTxPaging.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpld/app/ledger/LedgerMaster.h>
21#include <xrpld/app/main/Application.h>
22#include <xrpld/app/misc/Transaction.h>
23#include <xrpld/app/misc/detail/AccountTxPaging.h>
24
25#include <xrpl/protocol/Serializer.h>
26
27namespace ripple {
28
29void
32 std::uint32_t ledger_index,
33 std::string const& status,
34 Blob const& rawTxn,
35 Blob const& rawMeta,
36 Application& app)
37{
38 SerialIter it(makeSlice(rawTxn));
39 auto txn = std::make_shared<STTx const>(it);
40 std::string reason;
41
42 auto tr = std::make_shared<Transaction>(txn, reason, app);
43
44 auto metaset = std::make_shared<TxMeta>(tr->getID(), ledger_index, rawMeta);
45
46 // if properly formed meta is available we can use it to generate ctid
47 if (metaset->getAsObject().isFieldPresent(sfTransactionIndex))
48 tr->setStatus(
50 ledger_index,
51 metaset->getAsObject().getFieldU32(sfTransactionIndex),
52 app.config().NETWORK_ID);
53 else
54 tr->setStatus(Transaction::sqlTransactionStatus(status), ledger_index);
55
56 to.emplace_back(std::move(tr), metaset);
57};
58
59void
61{
62 if (auto l = app.getLedgerMaster().getLedgerBySeq(seq))
63 pendSaveValidated(app, l, false, false);
64}
65
66} // namespace ripple
virtual Config & config()=0
virtual LedgerMaster & getLedgerMaster()=0
uint32_t NETWORK_ID
Definition Config.h:156
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
static TransStatus sqlTransactionStatus(boost::optional< std::string > const &status)
T emplace_back(T... args)
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
void saveLedgerAsync(Application &app, std::uint32_t seq)
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Definition Slice.h:244
void convertBlobsToTxResult(RelationalDatabase::AccountTxs &to, std::uint32_t ledger_index, std::string const &status, Blob const &rawTxn, Blob const &rawMeta, Application &app)
bool pendSaveValidated(Application &app, std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
Save, or arrange to save, a fully-validated ledger Returns false on error.
Definition Ledger.cpp:997