rippled
ripple
app
paths
RippleLineCache.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/paths/RippleLineCache.h>
21
#include <ripple/ledger/OpenView.h>
22
23
namespace
ripple
{
24
25
RippleLineCache::RippleLineCache
(
std::shared_ptr<ReadView const>
const
& ledger)
26
{
27
// We want the caching that OpenView provides
28
// And we need to own a shared_ptr to the input view
29
// VFALCO TODO This should be a CachedLedger
30
mLedger
= std::make_shared<OpenView>(&*ledger, ledger);
31
}
32
33
std::vector<RippleState::pointer>
const
&
34
RippleLineCache::getRippleLines
(
AccountID
const
& accountID)
35
{
36
AccountKey
key(accountID,
hasher_
(accountID));
37
38
std::lock_guard
sl(
mLock
);
39
40
auto
[it, inserted] =
41
lines_
.emplace(key,
std::vector<RippleState::pointer>
());
42
43
if
(inserted)
44
it->second =
getRippleStateItems
(accountID, *
mLedger
);
45
46
return
it->second;
47
}
48
49
}
// namespace ripple
ripple::RippleLineCache::mLedger
std::shared_ptr< ReadView const > mLedger
Definition:
RippleLineCache.h:52
std::shared_ptr
STL class.
ripple::RippleLineCache::mLock
std::mutex mLock
Definition:
RippleLineCache.h:49
std::vector
STL class.
std::lock_guard
STL class.
ripple::RippleLineCache::AccountKey
Definition:
RippleLineCache.h:54
ripple::getRippleStateItems
std::vector< RippleState::pointer > getRippleStateItems(AccountID const &accountID, ReadView const &view)
Definition:
RippleState.cpp:70
ripple::base_uint< 160, detail::AccountIDTag >
ripple::RippleLineCache::RippleLineCache
RippleLineCache(std::shared_ptr< ReadView const > const &l)
Definition:
RippleLineCache.cpp:25
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
ripple::RippleLineCache::getRippleLines
std::vector< RippleState::pointer > const & getRippleLines(AccountID const &accountID)
Definition:
RippleLineCache.cpp:34
ripple::RippleLineCache::lines_
hash_map< AccountKey, std::vector< RippleState::pointer >, AccountKey::Hash > lines_
Definition:
RippleLineCache.h:94
ripple::RippleLineCache::hasher_
ripple::hardened_hash hasher_
Definition:
RippleLineCache.h:51
Generated by
1.8.17