mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-23 04:25:51 +00:00
Cleanups.
This commit is contained in:
@@ -69,7 +69,7 @@ SHAMap::pointer SHAMap::snapShot (bool isMutable)
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> SHAMap::getStack (uint256 const& id, bool include_nonmatching_leaf, bool partialOk)
|
||||
std::stack<SHAMapTreeNode::pointer> SHAMap::getStack (uint256 const& id, bool include_nonmatching_leaf)
|
||||
{
|
||||
// Walk the tree as far as possible to the specified identifier
|
||||
// produce a stack of nodes along the way, with the terminal node at the top
|
||||
@@ -92,9 +92,6 @@ std::stack<SHAMapTreeNode::pointer> SHAMap::getStack (uint256 const& id, bool in
|
||||
}
|
||||
catch (SHAMapMissingNode& mn)
|
||||
{
|
||||
if (partialOk)
|
||||
return stack;
|
||||
|
||||
mn.setTargetNode (id);
|
||||
throw;
|
||||
}
|
||||
@@ -317,7 +314,8 @@ SHAMapTreeNode* SHAMap::firstBelow (SHAMapTreeNode* node)
|
||||
do
|
||||
{
|
||||
// Walk down the tree
|
||||
if (node->hasItem ()) return node;
|
||||
if (node->hasItem ())
|
||||
return node;
|
||||
|
||||
bool foundNode = false;
|
||||
|
||||
@@ -468,10 +466,10 @@ SHAMapItem::pointer SHAMap::peekNextItem (uint256 const& id)
|
||||
|
||||
SHAMapItem::pointer SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNType& type)
|
||||
{
|
||||
// Get a pointer to the next item in the tree after a given item - item must be in tree
|
||||
// Get a pointer to the next item in the tree after a given item - item need not be in tree
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true, false);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true);
|
||||
|
||||
while (!stack.empty ())
|
||||
{
|
||||
@@ -494,8 +492,8 @@ SHAMapItem::pointer SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNT
|
||||
assert (firstNode);
|
||||
firstNode = firstBelow (firstNode);
|
||||
|
||||
if (!firstNode)
|
||||
throw std::runtime_error ("missing node");
|
||||
if (!firstNode || firstNode->isInner ())
|
||||
throw std::runtime_error ("missing/corrupt node");
|
||||
|
||||
type = firstNode->getType ();
|
||||
return firstNode->peekItem ();
|
||||
@@ -506,12 +504,12 @@ SHAMapItem::pointer SHAMap::peekNextItem (uint256 const& id, SHAMapTreeNode::TNT
|
||||
return no_item;
|
||||
}
|
||||
|
||||
// Get a pointer to the previous item in the tree after a given item - item must be in tree
|
||||
// Get a pointer to the previous item in the tree after a given item - item need not be in tree
|
||||
SHAMapItem::pointer SHAMap::peekPrevItem (uint256 const& id)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true, false);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true);
|
||||
|
||||
while (!stack.empty ())
|
||||
{
|
||||
@@ -596,7 +594,7 @@ bool SHAMap::delItem (uint256 const& id)
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
assert (mState != smsImmutable);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true, false);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (id, true);
|
||||
|
||||
if (stack.empty ())
|
||||
throw std::runtime_error ("missing node");
|
||||
@@ -677,7 +675,7 @@ bool SHAMap::addGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasMeta
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
assert (mState != smsImmutable);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (tag, true, false);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (tag, true);
|
||||
|
||||
if (stack.empty ())
|
||||
throw std::runtime_error ("missing node");
|
||||
@@ -775,7 +773,7 @@ bool SHAMap::updateGiveItem (SHAMapItem::ref item, bool isTransaction, bool hasM
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
assert (mState != smsImmutable);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (tag, true, false);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack (tag, true);
|
||||
|
||||
if (stack.empty ())
|
||||
throw std::runtime_error ("missing node");
|
||||
|
||||
@@ -193,7 +193,7 @@ private:
|
||||
static KeyCache <uint256, UptimeTimerAdapter> fullBelowCache;
|
||||
|
||||
void dirtyUp (std::stack<SHAMapTreeNode::pointer>& stack, uint256 const & target, uint256 prevHash);
|
||||
std::stack<SHAMapTreeNode::pointer> getStack (uint256 const & id, bool include_nonmatching_leaf, bool partialOk);
|
||||
std::stack<SHAMapTreeNode::pointer> getStack (uint256 const & id, bool include_nonmatching_leaf);
|
||||
SHAMapTreeNode::pointer walkTo (uint256 const & id, bool modify);
|
||||
SHAMapTreeNode* walkToPointer (uint256 const & id);
|
||||
SHAMapTreeNode::pointer checkCacheNode (const SHAMapNode&);
|
||||
|
||||
@@ -571,7 +571,7 @@ void SHAMap::getFetchPack (SHAMap* have, bool includeLeaves, int max,
|
||||
std::list<Blob > SHAMap::getTrustedPath (uint256 const& index)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl (mLock);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = SHAMap::getStack (index, false, false);
|
||||
std::stack<SHAMapTreeNode::pointer> stack = SHAMap::getStack (index, false);
|
||||
|
||||
if (stack.empty () || !stack.top ()->isLeaf ())
|
||||
throw std::runtime_error ("requested leaf not present");
|
||||
|
||||
Reference in New Issue
Block a user