mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cleanup and simplifications to SHAMap:
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
This commit is contained in:
committed by
Vinnie Falco
parent
315a8b6b60
commit
ec1e6b9385
@@ -57,7 +57,7 @@ SHAMapTreeNode::SHAMapTreeNode (const SHAMapTreeNode& node, std::uint32_t seq)
|
||||
}
|
||||
}
|
||||
|
||||
SHAMapTreeNode::SHAMapTreeNode (SHAMapItem::ref item,
|
||||
SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr<SHAMapItem> const& item,
|
||||
TNType type, std::uint32_t seq)
|
||||
: mItem (item)
|
||||
, mSeq (seq)
|
||||
@@ -402,7 +402,7 @@ void SHAMapTreeNode::addRaw (Serializer& s, SHANodeFormat format)
|
||||
assert (false);
|
||||
}
|
||||
|
||||
bool SHAMapTreeNode::setItem (SHAMapItem::ref i, TNType type)
|
||||
bool SHAMapTreeNode::setItem (std::shared_ptr<SHAMapItem> const& i, TNType type)
|
||||
{
|
||||
mType = type;
|
||||
mItem = i;
|
||||
@@ -437,12 +437,16 @@ void SHAMapTreeNode::makeInner ()
|
||||
mHash.zero ();
|
||||
}
|
||||
|
||||
#ifdef BEAST_DEBUG
|
||||
|
||||
void SHAMapTreeNode::dump (const SHAMapNodeID & id, beast::Journal journal)
|
||||
{
|
||||
if (journal.debug) journal.debug <<
|
||||
"SHAMapTreeNode(" << id.getNodeID () << ")";
|
||||
}
|
||||
|
||||
#endif // BEAST_DEBUG
|
||||
|
||||
std::string SHAMapTreeNode::getString (const SHAMapNodeID & id) const
|
||||
{
|
||||
std::string ret = "NodeID(";
|
||||
@@ -486,7 +490,7 @@ std::string SHAMapTreeNode::getString (const SHAMapNodeID & id) const
|
||||
}
|
||||
|
||||
// We are modifying an inner node
|
||||
bool SHAMapTreeNode::setChild (int m, uint256 const& hash, SHAMapTreeNode::ref child)
|
||||
bool SHAMapTreeNode::setChild (int m, uint256 const& hash, std::shared_ptr<SHAMapTreeNode> const& child)
|
||||
{
|
||||
assert ((m >= 0) && (m < 16));
|
||||
assert (mType == tnINNER);
|
||||
@@ -515,7 +519,7 @@ bool SHAMapTreeNode::setChild (int m, uint256 const& hash, SHAMapTreeNode::ref c
|
||||
}
|
||||
|
||||
// finished modifying, now make shareable
|
||||
void SHAMapTreeNode::shareChild (int m, SHAMapTreeNode::ref child)
|
||||
void SHAMapTreeNode::shareChild (int m, std::shared_ptr<SHAMapTreeNode> const& child)
|
||||
{
|
||||
assert ((m >= 0) && (m < 16));
|
||||
assert (mType == tnINNER);
|
||||
@@ -536,7 +540,7 @@ SHAMapTreeNode* SHAMapTreeNode::getChildPointer (int branch)
|
||||
return mChildren[branch].get ();
|
||||
}
|
||||
|
||||
SHAMapTreeNode::pointer SHAMapTreeNode::getChild (int branch)
|
||||
std::shared_ptr<SHAMapTreeNode> SHAMapTreeNode::getChild (int branch)
|
||||
{
|
||||
assert (branch >= 0 && branch < 16);
|
||||
assert (isInnerNode ());
|
||||
@@ -546,7 +550,7 @@ SHAMapTreeNode::pointer SHAMapTreeNode::getChild (int branch)
|
||||
return mChildren[branch];
|
||||
}
|
||||
|
||||
void SHAMapTreeNode::canonicalizeChild (int branch, SHAMapTreeNode::pointer& node)
|
||||
void SHAMapTreeNode::canonicalizeChild (int branch, std::shared_ptr<SHAMapTreeNode>& node)
|
||||
{
|
||||
assert (branch >= 0 && branch < 16);
|
||||
assert (isInnerNode ());
|
||||
|
||||
Reference in New Issue
Block a user