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/ledger/LedgerToJson.h>
22#include <xrpld/app/main/Application.h>
23#include <xrpld/app/misc/Transaction.h>
24#include <xrpld/app/misc/detail/AccountTxPaging.h>
25#include <xrpl/protocol/Serializer.h>
26#include <xrpl/protocol/UintTypes.h>
27#include <boost/format.hpp>
28#include <memory>
29
30namespace ripple {
31
32void
35 std::uint32_t ledger_index,
36 std::string const& status,
37 Blob const& rawTxn,
38 Blob const& rawMeta,
39 Application& app)
40{
41 SerialIter it(makeSlice(rawTxn));
42 auto txn = std::make_shared<STTx const>(it);
43 std::string reason;
44
45 auto tr = std::make_shared<Transaction>(txn, reason, app);
46
47 tr->setStatus(Transaction::sqlTransactionStatus(status));
48 tr->setLedger(ledger_index);
49
50 auto metaset =
51 std::make_shared<TxMeta>(tr->getID(), tr->getLedger(), rawMeta);
52
53 to.emplace_back(std::move(tr), metaset);
54};
55
56void
58{
59 if (auto l = app.getLedgerMaster().getLedgerBySeq(seq))
60 pendSaveValidated(app, l, false, false);
61}
62
63} // namespace ripple
virtual LedgerMaster & getLedgerMaster()=0
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
static TransStatus sqlTransactionStatus(boost::optional< std::string > const &status)
Definition: Transaction.cpp:67
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
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:243
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:1002