rippled
ripple
app
ledger
AcceptedLedger.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/AcceptedLedger.h>
21
#include <ripple/app/main/Application.h>
22
#include <
algorithm
>
23
24
namespace
ripple
{
25
26
AcceptedLedger::AcceptedLedger
(
27
std::shared_ptr<ReadView const>
const
& ledger,
28
Application
& app)
29
: mLedger(ledger)
30
{
31
transactions_
.reserve(256);
32
33
auto
insertAll = [&](
auto
const
& txns) {
34
for
(
auto
const
& item : txns)
35
transactions_
.emplace_back(std::make_unique<AcceptedLedgerTx>(
36
ledger, item.first, item.second));
37
};
38
39
if
(app.
config
().
reporting
())
40
{
41
auto
const
txs =
flatFetchTransactions
(*ledger, app);
42
transactions_
.reserve(txs.size());
43
insertAll(txs);
44
}
45
else
46
{
47
transactions_
.reserve(256);
48
insertAll(ledger->txs);
49
}
50
51
std::sort
(
52
transactions_
.begin(),
53
transactions_
.end(),
54
[](
auto
const
& a,
auto
const
& b) {
55
return a->getTxnSeq() < b->getTxnSeq();
56
});
57
}
58
59
}
// namespace ripple
ripple::Application
Definition:
Application.h:115
std::shared_ptr
STL class.
std::sort
T sort(T... args)
algorithm
ripple::AcceptedLedger::AcceptedLedger
AcceptedLedger(std::shared_ptr< ReadView const > const &ledger, Application &app)
Definition:
AcceptedLedger.cpp:26
ripple::Config::reporting
bool reporting() const
Definition:
Config.h:337
ripple::AcceptedLedger::transactions_
std::vector< std::unique_ptr< AcceptedLedgerTx > > transactions_
Definition:
AcceptedLedger.h:77
ripple::Application::config
virtual Config & config()=0
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::flatFetchTransactions
std::vector< std::pair< std::shared_ptr< STTx const >, std::shared_ptr< STObject const > > > flatFetchTransactions(Application &app, std::vector< uint256 > &nodestoreHashes)
Definition:
Ledger.cpp:1151
Generated by
1.8.17