rippled
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 <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/LedgerToJson.h>
22 #include <ripple/app/main/Application.h>
23 #include <ripple/app/misc/Transaction.h>
24 #include <ripple/app/misc/impl/AccountTxPaging.h>
25 #include <ripple/protocol/Serializer.h>
26 #include <ripple/protocol/UintTypes.h>
27 #include <boost/format.hpp>
28 #include <memory>
29 
30 namespace ripple {
31 
32 void
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 
56 void
58 {
59  if (auto l = app.getLedgerMaster().getLedgerBySeq(seq))
60  pendSaveValidated(app, l, false, false);
61 }
62 
63 } // namespace ripple
ripple::Transaction::sqlTransactionStatus
static TransStatus sqlTransactionStatus(boost::optional< std::string > const &status)
Definition: Transaction.cpp:69
ripple::Application
Definition: Application.h:115
ripple::makeSlice
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:241
std::string
STL class.
std::vector
STL class.
ripple::convertBlobsToTxResult
void convertBlobsToTxResult(RelationalDatabase::AccountTxs &to, std::uint32_t ledger_index, std::string const &status, Blob const &rawTxn, Blob const &rawMeta, Application &app)
Definition: AccountTxPaging.cpp:33
ripple::Application::getLedgerMaster
virtual LedgerMaster & getLedgerMaster()=0
ripple::saveLedgerAsync
void saveLedgerAsync(Application &app, std::uint32_t seq)
Definition: AccountTxPaging.cpp:57
ripple::LedgerMaster::getLedgerBySeq
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
Definition: LedgerMaster.cpp:1818
ripple::SerialIter
Definition: Serializer.h:310
std::uint32_t
memory
std::vector::emplace_back
T emplace_back(T... args)
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::pendSaveValidated
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:1005