3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/SHAMapHash.h>
5#include <xrpl/basics/Slice.h>
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/basics/contract.h>
8#include <xrpl/protocol/Serializer.h>
9#include <xrpl/shamap/SHAMap.h>
10#include <xrpl/shamap/SHAMapAddNode.h>
11#include <xrpl/shamap/SHAMapLeafNode.h>
12#include <xrpl/shamap/SHAMapNodeID.h>
13#include <xrpl/shamap/SHAMapTreeNode.h>
95 toLeaf(
unsigned int depth,
unsigned int seed = 1)
138 nodeAt(depth)->serializeWithPrefix(s);
153 for (
auto depth = firstDepth; depth <=
deepestDepth; ++depth)
154 data.emplace_back(
idAt(depth),
nodeAt(depth));
216 :
nodes(leafDepth.value_or(
SHAMap::kLeafDepth) + 1)
245 nodes[*leafDepth] = leaf;
275 for (
auto depth = deepest + 1; depth > 0;)
287 s.
add8(
static_cast<unsigned char>(branch));
299 decoyHash.
begin()[0] = 0xDE;
300 decoyHash.
begin()[1] = 0xC0;
301 decoyHash.
begin()[2] =
static_cast<unsigned char>(depth);
309 childHash = node->getHash();
310 nodes[depth] = std::move(node);
UInt256 const & asUInt256() const
Identifies a node inside a SHAMap.
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.
static SHAMapTreeNodePtr makeFromWire(Slice rawNode)
static constexpr unsigned int kLeafDepth
The depth of the hash map: data is only present in the leaves.
SHAMapAddNode addRootNode(SHAMapHash const &hash, SHAMapTreeNodePtr rootNode, SHAMapSyncFilter const *filter)
Add a root node to the SHAMap during synchronization.
SHAMapAddNode addKnownNode(SHAMapNodeID const &nodeID, SHAMapTreeNodePtr treeNode, SHAMapSyncFilter const *filter)
Add a known node at a specific position in the SHAMap during synchronization.
Blob const & peekData() const
int addBitString(BaseUInt< Bits, Tag > const &v)
int add8(unsigned char byteValue)
int addRaw(Blob const &vector)
std::size_t size() const noexcept
intr_ptr::SharedPtr< SHAMapTreeNode > SHAMapTreeNodePtr
static constexpr unsigned char const kWireTypeCompressedInner
Slice makeSlice(std::array< T, N > const &a)
constexpr std::size_t kMinShaMapItemBytes
UInt256 const & leafKey(SHAMapTreeNode const &node)
Return the key of the item held by a SHAMap leaf node.
static constexpr unsigned char const kWireTypeTransaction
unsigned int selectBranch(SHAMapNodeID const &id, UInt256 const &hash)
Returns the branch that would contain the given hash.
std::vector< unsigned char > Blob
Storage for linear binary data.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
DeepChain(unsigned int seed=1)
A chain of inner nodes reaching SHAMap::kLeafDepth, a depth only a leaf may occupy.
A chain of inner nodes in wire form, from the root down to one deepest node, each with one real child...
unsigned int deepestDepth
DeepChain(unsigned int seed=1)
A chain of inner nodes reaching SHAMap::kLeafDepth, a depth only a leaf may occupy.
Blob prefixedNodeAt(unsigned int depth) const
The same node in the prefixed form used for storage and fetch packs, which is what hashes to the node...
static constexpr std::size_t kLeafItemBytes
The payload size of the leaf toLeaf() builds, which is the smallest a SHAMap item may be.
static DeepChain withDecoys(unsigned int seed=1)
The same chain, with an unresolvable second child at every level, so a backed map's descendAsync() po...
SHAMapAddNode addOffendingNode(SHAMap &map) const
Offer the deepest node, which for a fabricated chain is the inner node at SHAMap::kLeafDepth,...
bool fill(SHAMap &map) const
Fill a synching map, stopping one level short of the deepest node so the caller offers that one itsel...
std::vector< std::pair< SHAMapNodeID, SHAMapTreeNodePtr > > nodesBelowRoot(unsigned int firstDepth=1) const
Every node below the root, down to and including the deepest one.
std::vector< SHAMapTreeNodePtr > nodes
SHAMapTreeNodePtr nodeAt(unsigned int depth) const
The node the chain holds at the given depth, root first.
SHAMapNodeID idAt(unsigned int depth) const
Where the node at the given depth claims to belong, which is on the path to pathKey.
void buildInnersDownTo(unsigned int deepest, SHAMapHash childHash, Decoy decoy)
Fill in inner nodes, each with one real child (and, under Decoy::Yes, an additional unresolvable seco...
static DeepChain toLeaf(unsigned int depth, unsigned int seed=1)
A chain ending in a real transaction leaf, which completes an acquisition.
DeepChain(std::optional< unsigned int > leafDepth, unsigned int seed, Decoy decoy)
Build any of the shapes.