mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
SHAMapTreeNode * Remove SHAMapTreeNode::pointer and SHAMapTreeNode::ref. * Add std includes necessary to make the header standalone. * Remove implementation from the SHAMapTreeNode declaration. * Make clear what part of SHAMapTreeNode is: 1) Truly public. 2) Used only by SHAMap. 3) Truly private to SHAMapTreeNode. SHAMapItem * Remove SHAMapItem::pointer and SHAMapItem::ref. * Add std includes necessary to make the header standalone. * Remove implementation from the SHAMapItem declaration. * Make clear what part of SHAMapItem is: 1) Truly public. 2) Used only by SHAMapTreeNode. 3) Truly private to SHAMapItem. SHAMapSyncFilter * Add override for SHAMapSyncFilter-derived functions. * Add missing header. * Default the destructor and delete the SHAMapSyncFilter copy members. SHAMapNodeID * Remove unused mHash member. * Remove unused std::hash and boost::hash specializations. * Remove unused constructor. * Remove unused comparison with uint256. * Remove unused getNodeID (int depth, uint256 const& hash). * Remove virtual specifier from getString(). * Fix operator<= and operator>=. * Document what API is used outside of SHAMap. * Move inline definitions outside of the class declaration. SHAMapMissingNode * Make SHAMapType a enum class to prevent unwanted conversions. * Remove needless ~SHAMapMissingNode() declaration/definition. * Add referenced std includes. SHAMapAddNode * Make SHAMapAddNode (int good, int bad, int duplicate) ctor private. * Move all member function definitions out of the class declaration. * Remove dependence on beast::lexicalCastThrow. * Make getGood() const. * Make get() const. * Add #include <string>. SHAMap * Remove unused enum STATE_MAP_BUCKETS. * Remove unused getCountedObjectName(). * Remove SHAMap::pointer * Remove SHAMap::ref * Remove unused fetchPackEntry_t. * Remove inline member function definitions from class declaration. * Remove unused getTrustedPath. * Remove unused getPath. * Remove unused visitLeavesInternal. * Make SHAMapState an enum class. * Explicitly delete SHAMap copy members. * Reduce access to nested types as much as possible. * Normalize member data names to one style. * Change last of the typedefs to usings under shamap. * Reorder some includes ripple-first, beast-second. * Declare a few constructions from make_shared with auto. * Mark those SHAMap member functions which can be, with const. * Add missing includes
75 lines
2.6 KiB
C++
75 lines
2.6 KiB
C++
//------------------------------------------------------------------------------
|
|
/*
|
|
This file is part of rippled: https://github.com/ripple/rippled
|
|
Copyright (c) 2012, 2013 Ripple Labs Inc.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
//==============================================================================
|
|
|
|
#include <BeastConfig.h>
|
|
#include <ripple/app/ledger/AcceptedLedger.h>
|
|
#include <ripple/basics/Log.h>
|
|
#include <ripple/basics/seconds_clock.h>
|
|
|
|
namespace ripple {
|
|
|
|
// VFALCO TODO Remove this global and make it a member of the App
|
|
// Use a dependency injection to give AcceptedLedger access.
|
|
//
|
|
TaggedCache <uint256, AcceptedLedger> AcceptedLedger::s_cache (
|
|
"AcceptedLedger", 4, 60, get_seconds_clock (),
|
|
deprecatedLogs().journal("TaggedCache"));
|
|
|
|
AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
|
|
{
|
|
SHAMap& txSet = *ledger->peekTransactionMap ();
|
|
|
|
for (std::shared_ptr<SHAMapItem> item = txSet.peekFirstItem (); item;
|
|
item = txSet.peekNextItem (item->getTag ()))
|
|
{
|
|
SerialIter sit (item->peekSerializer ());
|
|
insert (std::make_shared<AcceptedLedgerTx> (ledger, std::ref (sit)));
|
|
}
|
|
}
|
|
|
|
AcceptedLedger::pointer AcceptedLedger::makeAcceptedLedger (Ledger::ref ledger)
|
|
{
|
|
AcceptedLedger::pointer ret = s_cache.fetch (ledger->getHash ());
|
|
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = AcceptedLedger::pointer (new AcceptedLedger (ledger));
|
|
s_cache.canonicalize (ledger->getHash (), ret);
|
|
return ret;
|
|
}
|
|
|
|
void AcceptedLedger::insert (AcceptedLedgerTx::ref at)
|
|
{
|
|
assert (mMap.find (at->getIndex ()) == mMap.end ());
|
|
mMap.insert (std::make_pair (at->getIndex (), at));
|
|
}
|
|
|
|
AcceptedLedgerTx::pointer AcceptedLedger::getTxn (int i) const
|
|
{
|
|
map_t::const_iterator it = mMap.find (i);
|
|
|
|
if (it == mMap.end ())
|
|
return AcceptedLedgerTx::pointer ();
|
|
|
|
return it->second;
|
|
}
|
|
|
|
} // ripple
|