rippled
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 
27 {
28  // We want the caching that OpenView provides
29  // And we need to own a shared_ptr to the input view
30  // VFALCO TODO This should be a CachedLedger
31  mLedger = std::make_shared<OpenView>(&*ledger, ledger);
32 }
33 
36 {
37  AccountKey key (accountID, hasher_ (accountID));
38 
40 
41  auto [it, inserted] = lines_.emplace (key,
43 
44  if (inserted)
45  it->second = getRippleStateItems (
46  accountID, *mLedger);
47 
48  return it->second;
49 }
50 
51 } // ripple
ripple::RippleLineCache::mLedger
std::shared_ptr< ReadView const > mLedger
Definition: RippleLineCache.h:54
std::shared_ptr
STL class.
ripple::RippleLineCache::mLock
std::mutex mLock
Definition: RippleLineCache.h:51
std::vector
STL class.
std::lock_guard
STL class.
ripple::RippleLineCache::AccountKey
Definition: RippleLineCache.h:56
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:35
ripple::RippleLineCache::hasher_
ripple::hardened_hash hasher_
Definition: RippleLineCache.h:53
ripple::RippleLineCache::lines_
hash_map< AccountKey, std::vector< RippleState::pointer >, AccountKey::Hash > lines_
Definition: RippleLineCache.h:97