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/basics/Log.h>
22
#include <ripple/basics/chrono.h>
23
24
namespace
ripple
{
25
26
AcceptedLedger::AcceptedLedger
(
27
std::shared_ptr<ReadView const>
const
& ledger,
28
AccountIDCache
const
& accountCache,
29
Logs
& logs)
30
: mLedger(ledger)
31
{
32
for
(
auto
const
& item : ledger->txs)
33
{
34
insert
(std::make_shared<AcceptedLedgerTx>(
35
ledger, item.first, item.second, accountCache, logs));
36
}
37
}
38
39
void
40
AcceptedLedger::insert
(
AcceptedLedgerTx::ref
at)
41
{
42
assert(
mMap
.
find
(at->getIndex()) ==
mMap
.
end
());
43
mMap
.
insert
(
std::make_pair
(at->getIndex(), at));
44
}
45
46
AcceptedLedgerTx::pointer
47
AcceptedLedger::getTxn
(
int
i)
const
48
{
49
map_t::const_iterator it =
mMap
.
find
(i);
50
51
if
(it ==
mMap
.
end
())
52
return
AcceptedLedgerTx::pointer
();
53
54
return
it->second;
55
}
56
57
}
// namespace ripple
std::shared_ptr
STL class.
ripple::AcceptedLedger::getTxn
AcceptedLedgerTx::pointer getTxn(int) const
Definition:
AcceptedLedger.cpp:47
ripple::Logs
Manages partitions for logging.
Definition:
Log.h:48
ripple::AcceptedLedger::AcceptedLedger
AcceptedLedger(std::shared_ptr< ReadView const > const &ledger, AccountIDCache const &accountCache, Logs &logs)
Definition:
AcceptedLedger.cpp:26
std::map::find
T find(T... args)
ripple::AccountIDCache
Caches the base58 representations of AccountIDs.
Definition:
AccountID.h:118
ripple::AcceptedLedgerTx::pointer
std::shared_ptr< AcceptedLedgerTx > pointer
Definition:
AcceptedLedgerTx.h:53
ripple::AcceptedLedger::insert
void insert(AcceptedLedgerTx::ref)
Definition:
AcceptedLedger.cpp:40
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
std::map::insert
T insert(T... args)
std::make_pair
T make_pair(T... args)
std::map::end
T end(T... args)
ripple::AcceptedLedger::mMap
map_t mMap
Definition:
AcceptedLedger.h:84
Generated by
1.8.17