|
xrpld
|
A chain of inner nodes in wire form, from the root down to one deepest node, each with one real child and, under withDecoys(), an unresolvable second one. More...
#include <DeepChain.h>

Public Member Functions | |
| DeepChain (unsigned int seed=1) | |
| A chain of inner nodes reaching SHAMap::kLeafDepth, a depth only a leaf may occupy. | |
| 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. | |
| 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's own hash. | |
| std::vector< std::pair< SHAMapNodeID, SHAMapTreeNodePtr > > | nodesBelowRoot (unsigned int firstDepth=1) const |
| Every node below the root, down to and including the deepest one. | |
| bool | fill (SHAMap &map) const |
| Fill a synching map, stopping one level short of the deepest node so the caller offers that one itself. | |
| SHAMapAddNode | addOffendingNode (SHAMap &map) const |
| Offer the deepest node, which for a fabricated chain is the inner node at SHAMap::kLeafDepth, a depth only a leaf may occupy. | |
Static Public Member Functions | |
| static DeepChain | withDecoys (unsigned int seed=1) |
| The same chain, with an unresolvable second child at every level, so a backed map's descendAsync() posts a real asynchronous read per level. | |
| static DeepChain | toLeaf (unsigned int depth, unsigned int seed=1) |
| A chain ending in a real transaction leaf, which completes an acquisition. | |
Public Attributes | |
| std::vector< SHAMapTreeNodePtr > | nodes |
| SHAMapHash | rootHash |
| UInt256 | pathKey |
| unsigned int | deepestDepth {SHAMap::kLeafDepth} |
Static Public Attributes | |
| static constexpr std::size_t | kLeafItemBytes = kMinShaMapItemBytes |
| The payload size of the leaf toLeaf() builds, which is the smallest a SHAMap item may be. | |
Private Types | |
| enum class | Decoy { No , Yes } |
Private Member Functions | |
| DeepChain (std::optional< unsigned int > leafDepth, unsigned int seed, Decoy decoy) | |
| Build any of the shapes. | |
| 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 second child), from the root down to the given depth, and record the root hash. | |
A chain of inner nodes in wire form, from the root down to one deepest node, each with one real child and, under withDecoys(), an unresolvable second one.
Built bottom-up, so every node hashes correctly and the root hash commits to the whole shape. Each node sits on the branch pathKey selects at its depth.
Two shapes: the constructors run inner nodes all the way to SHAMap::kLeafDepth, a depth only a leaf may occupy, and toLeaf() ends at a real transaction leaf.
Depends only on libxrpl, so either test tree can include it. The xrpld counterpart is test::packetFor() in src/test/app/AcquireTestHelpers.h.
Definition at line 37 of file DeepChain.h.
|
strongprivate |
| Enumerator | |
|---|---|
| No | |
| Yes | |
Definition at line 205 of file DeepChain.h.
|
explicit |
A chain of inner nodes reaching SHAMap::kLeafDepth, a depth only a leaf may occupy.
| seed | Varies the chain's nodes. Two chains built from one seed hold the same nodes, which caches and fetch packs key by hash. |
Definition at line 63 of file DeepChain.h.
|
private |
Build any of the shapes.
| leafDepth | Where a real transaction leaf sits, or nullopt to run inner nodes all the way to SHAMap::kLeafDepth instead. |
| seed | Varies the chain's contents. See the public entry points. |
| decoy | Whether every level carries an unresolvable second child. |
Definition at line 215 of file DeepChain.h.
|
staticnodiscard |
The same chain, with an unresolvable second child at every level, so a backed map's descendAsync() posts a real asynchronous read per level.
Offered only for this shape: the decoy sits on branch 1, which is free only while pathKey is zero.
| seed | Varies the whole chain. See the constructor. |
Definition at line 78 of file DeepChain.h.
|
staticnodiscard |
A chain ending in a real transaction leaf, which completes an acquisition.
| depth | Where the leaf sits, at most SHAMap::kLeafDepth. Zero puts the leaf at the root. A deeper value throws std::logic_error, since no leaf can sit there. |
| seed | Varies the leaf's contents, and so the whole chain. See the constructor. |
Definition at line 95 of file DeepChain.h.
|
nodiscard |
The node the chain holds at the given depth, root first.
| depth | The depth of the node to return, at most deepestDepth. |
Definition at line 109 of file DeepChain.h.
|
nodiscard |
Where the node at the given depth claims to belong, which is on the path to pathKey.
| depth | The depth of the node to locate. |
Definition at line 122 of file DeepChain.h.
|
nodiscard |
The same node in the prefixed form used for storage and fetch packs, which is what hashes to the node's own hash.
| depth | The depth of the node to serialize. |
Definition at line 135 of file DeepChain.h.
|
nodiscard |
Every node below the root, down to and including the deepest one.
| firstDepth | The shallowest node to include, so a caller can feed the chain in more than one batch. |
Definition at line 150 of file DeepChain.h.
|
nodiscard |
Fill a synching map, stopping one level short of the deepest node so the caller offers that one itself.
Reports rather than asserts: the two binaries sharing this header use different test frameworks.
| map | The map to fill. |
Definition at line 170 of file DeepChain.h.
|
nodiscard |
Offer the deepest node, which for a fabricated chain is the inner node at SHAMap::kLeafDepth, a depth only a leaf may occupy.
A chain whose only node is the root has nothing below it to offer, and addKnownNode() refuses a root ID, so a toLeaf(0) chain throws std::logic_error.
| map | The map to offer the node to, filled by fill() first. |
Definition at line 196 of file DeepChain.h.
|
private |
Fill in inner nodes, each with one real child (and, under Decoy::Yes, an additional unresolvable second child), from the root down to the given depth, and record the root hash.
Bottom-up, since each node's hash covers the child hash below it.
| deepest | The depth of the deepest inner node to build. May be SHAMap::kLeafDepth, which is the fabricated chain's whole point. |
| childHash | What that deepest inner node points at. |
| decoy | Whether to add an unresolvable second child at every level. |
Definition at line 270 of file DeepChain.h.
| std::vector<SHAMapTreeNodePtr> xrpl::tests::DeepChain::nodes |
Definition at line 40 of file DeepChain.h.
| SHAMapHash xrpl::tests::DeepChain::rootHash |
Definition at line 41 of file DeepChain.h.
| UInt256 xrpl::tests::DeepChain::pathKey |
Definition at line 45 of file DeepChain.h.
| unsigned int xrpl::tests::DeepChain::deepestDepth {SHAMap::kLeafDepth} |
Definition at line 48 of file DeepChain.h.
|
staticconstexpr |
The payload size of the leaf toLeaf() builds, which is the smallest a SHAMap item may be.
Definition at line 54 of file DeepChain.h.