xrpld
Loading...
Searching...
No Matches
xrpl::SHAMapNodeID Class Reference

Identifies a node inside a SHAMap. More...

#include <SHAMapNodeID.h>

Inheritance diagram for xrpl::SHAMapNodeID:
Collaboration diagram for xrpl::SHAMapNodeID:

Public Member Functions

 SHAMapNodeID ()=default
 SHAMapNodeID (SHAMapNodeID const &other)=default
 SHAMapNodeID (unsigned int depth, UInt256 const &hash)
SHAMapNodeID & operator= (SHAMapNodeID const &other)=default
bool isRoot () const
std::string getRawString () const
unsigned int getDepth () const
UInt256 const & getNodeID () const
SHAMapNodeID getChildNodeID (unsigned int branch) const
bool isPrefixOf (UInt256 const &key) const
 Test whether this node ID lies on the path to the given leaf key.
std::strong_ordering operator<=> (SHAMapNodeID const &n) const
 Comparison operators.
bool operator== (SHAMapNodeID const &n) const
 Equality, which the spaceship above does not provide.

Static Public Member Functions

static SHAMapNodeID createID (unsigned int depth, UInt256 const &key)
 Create a SHAMapNodeID of a node with the depth of the node and the key of a leaf.

Public Attributes

friend Object

Static Private Member Functions

static auto & getCounter () noexcept

Private Attributes

UInt256 id_
unsigned int depth_ = 0

Detailed Description

Identifies a node inside a SHAMap.

Definition at line 19 of file SHAMapNodeID.h.

Constructor & Destructor Documentation

◆ SHAMapNodeID() [1/3]

xrpl::SHAMapNodeID::SHAMapNodeID ( )
default

◆ SHAMapNodeID() [2/3]

xrpl::SHAMapNodeID::SHAMapNodeID ( SHAMapNodeID const & other)
default

◆ SHAMapNodeID() [3/3]

xrpl::SHAMapNodeID::SHAMapNodeID ( unsigned int depth,
UInt256 const & hash )

Definition at line 62 of file libxrpl/shamap/SHAMapNodeID.cpp.

Member Function Documentation

◆ operator=()

SHAMapNodeID & xrpl::SHAMapNodeID::operator= ( SHAMapNodeID const & other)
default

◆ isRoot()

bool xrpl::SHAMapNodeID::isRoot ( ) const
nodiscard

Definition at line 34 of file SHAMapNodeID.h.

◆ getRawString()

std::string xrpl::SHAMapNodeID::getRawString ( ) const
nodiscard

Definition at line 85 of file libxrpl/shamap/SHAMapNodeID.cpp.

◆ getDepth()

unsigned int xrpl::SHAMapNodeID::getDepth ( ) const
nodiscard

Definition at line 44 of file SHAMapNodeID.h.

◆ getNodeID()

UInt256 const & xrpl::SHAMapNodeID::getNodeID ( ) const
nodiscard

Definition at line 50 of file SHAMapNodeID.h.

◆ getChildNodeID()

SHAMapNodeID xrpl::SHAMapNodeID::getChildNodeID ( unsigned int branch) const
nodiscard

Definition at line 94 of file libxrpl/shamap/SHAMapNodeID.cpp.

◆ isPrefixOf()

bool xrpl::SHAMapNodeID::isPrefixOf ( UInt256 const & key) const
nodiscard

Test whether this node ID lies on the path to the given leaf key.

A node at depth d identifies the tree path spelled by the first d nibbles of its key, so any leaf beneath it must agree on that prefix. A node ID that fails this test names a different subtree than the one it was built for.

Parameters
keythe key of a leaf below this node
Returns
whether this node ID is a prefix of the leaf key

Definition at line 122 of file libxrpl/shamap/SHAMapNodeID.cpp.

◆ createID()

SHAMapNodeID xrpl::SHAMapNodeID::createID ( unsigned int depth,
UInt256 const & key )
static

Create a SHAMapNodeID of a node with the depth of the node and the key of a leaf.

Parameters
depththe depth of the node
keythe key of a leaf
Returns
SHAMapNodeID of the node

Definition at line 171 of file libxrpl/shamap/SHAMapNodeID.cpp.

◆ operator<=>()

std::strong_ordering xrpl::SHAMapNodeID::operator<=> ( SHAMapNodeID const & n) const

Comparison operators.

<, >, <= and >= are synthesized from the spaceship. It is written out rather than defaulted because the ordering is by depth first, and the members are not declared in that order.

Definition at line 90 of file SHAMapNodeID.h.

◆ operator==()

bool xrpl::SHAMapNodeID::operator== ( SHAMapNodeID const & n) const

Equality, which the spaceship above does not provide.

Only a defaulted operator<=> implicitly declares a defaulted operator==; the one above is user-provided, so == has to be written. It cannot be defaulted either, because a defaulted == would also compare the CountedObject base, which is not equality comparable.

Definition at line 105 of file SHAMapNodeID.h.

◆ getCounter()

auto & xrpl::CountedObject< SHAMapNodeID >::getCounter ( )
staticprivatenoexceptinherited

Definition at line 113 of file CountedObject.h.

Member Data Documentation

◆ id_

UInt256 xrpl::SHAMapNodeID::id_
private

Definition at line 22 of file SHAMapNodeID.h.

◆ depth_

unsigned int xrpl::SHAMapNodeID::depth_ = 0
private

Definition at line 23 of file SHAMapNodeID.h.

◆ Object

Definition at line 138 of file CountedObject.h.