xrpld
Loading...
Searching...
No Matches
xrpl::SHAMap::NodePathStack Class Reference

A path from the root of the map down to some node, pairing each node with the ID naming its position. More...

Collaboration diagram for xrpl::SHAMap::NodePathStack:

Public Member Functions

bool empty () const
std::size_t size () const
std::pair< SHAMapTreeNodePtr, SHAMapNodeID > const & top () const
void pop ()
void clear ()
void pushRoot (SHAMapTreeNodePtr node)
 Start a path at the root of the map, whose ID is the zero-depth ID by definition.
void pushChild (SHAMapTreeNodePtr node, unsigned int branch)
 Extend the path to the child of the current node reached by branch.
void pushNode (SHAMapTreeNodePtr node, UInt256 const &target)
 Extend the path to a node lying on the path to target.

Private Attributes

std::stack< std::pair< SHAMapTreeNodePtr, SHAMapNodeID > > stack_

Detailed Description

A path from the root of the map down to some node, pairing each node with the ID naming its position.

The two halves of an entry must agree, and the only way to get that wrong is to compute an ID from the wrong branch. So this type does not accept an ID at all: every push takes the branch being descended and derives the ID itself, so a node and its ID cannot disagree. Reads are exposed through the same accessors a std::stack would offer.

Definition at line 432 of file SHAMap.h.

Member Function Documentation

◆ empty()

bool xrpl::SHAMap::NodePathStack::empty ( ) const
nodiscard

Definition at line 436 of file SHAMap.h.

◆ size()

std::size_t xrpl::SHAMap::NodePathStack::size ( ) const
nodiscard

Definition at line 442 of file SHAMap.h.

◆ top()

std::pair< SHAMapTreeNodePtr, SHAMapNodeID > const & xrpl::SHAMap::NodePathStack::top ( ) const
nodiscard

Definition at line 448 of file SHAMap.h.

◆ pop()

void xrpl::SHAMap::NodePathStack::pop ( )

Definition at line 455 of file SHAMap.h.

◆ clear()

void xrpl::SHAMap::NodePathStack::clear ( )

Definition at line 462 of file SHAMap.h.

◆ pushRoot()

void xrpl::SHAMap::NodePathStack::pushRoot ( SHAMapTreeNodePtr node)

Start a path at the root of the map, whose ID is the zero-depth ID by definition.

Definition at line 471 of file SHAMap.h.

◆ pushChild()

void xrpl::SHAMap::NodePathStack::pushChild ( SHAMapTreeNodePtr node,
unsigned int branch )

Extend the path to the child of the current node reached by branch.

A node keeps the depth it was reached at, never a normalized kLeafDepth. Only a leaf may sit at kLeafDepth, since an inner node there would have no branch left to select.

Definition at line 484 of file SHAMap.h.

◆ pushNode()

void xrpl::SHAMap::NodePathStack::pushNode ( SHAMapTreeNodePtr node,
UInt256 const & target )

Extend the path to a node lying on the path to target.

For nodes not reached by descending a known branch: the walk tracks only the key it is heading for, or the node is newly created. Either way target selects the branch.

Definition at line 508 of file SHAMap.h.

Member Data Documentation

◆ stack_

std::stack<std::pair<SHAMapTreeNodePtr, SHAMapNodeID> > xrpl::SHAMap::NodePathStack::stack_
private

Definition at line 521 of file SHAMap.h.