CatapultServer
v0.5.0.1 (Elephant)
|
Represents a compact patricia tree. More...
Classes | |
struct | PathValuePairRef |
Public Types | |
using | KeyType = typename TEncoder::KeyType |
using | ValueType = typename TEncoder::ValueType |
Public Member Functions | |
PatriciaTree (TDataSource &dataSource) | |
Creates a tree around a dataSource. More... | |
Hash256 | root () const |
Gets the root hash that uniquely identifies this tree. More... | |
void | set (const KeyType &key, const ValueType &value) |
Sets key to value in the tree. More... | |
bool | unset (const KeyType &key) |
Removes the value associated with key from the tree. More... | |
std::pair< Hash256, bool > | lookup (const KeyType &key, std::vector< TreeNode > &nodePath) const |
Tries to find the value associated with key in the tree and stores proof of existence or not in nodePath. More... | |
bool | tryLoad (const Hash256 &rootHash) |
Loads the node with hash rootHash and sets it as the root node. More... | |
void | setRoot (const TreeNode &rootNode) |
Sets the root to rootNode. More... | |
void | clear () |
Clears the tree. More... | |
void | saveAll () |
Saves all tree nodes to the underlying data source. More... | |
Private Member Functions | |
TreeNode | set (const TreeNode &node, const PathValuePairRef &newPair) |
LeafTreeNode | createLeaf (const PathValuePairRef &pair) |
BranchTreeNode | branchLeafNode (const LeafTreeNode &leafNode, const PathValuePairRef &newPair) |
BranchTreeNode | updateBranchLink (BranchTreeNode &&branchNode, const PathValuePairRef &newPair) |
BranchTreeNode | insertNewPairIntoBranch (BranchTreeNode &branchNode, const TreeNodePath &branchPath, size_t differenceIndex, const PathValuePairRef &newPair) |
bool | unset (const TreeNode &node, const TreeNodePath &keyPath, TreeNode &updatedNode, bool &canMerge) |
TreeNode | unsetBranchLink (BranchTreeNode &&branchNode, size_t linkIndex) |
TreeNode | updateBranchLink (BranchTreeNode &&branchNode, size_t linkIndex, const TreeNode &linkedNode) |
std::pair< Hash256, bool > | lookup (const TreeNode &node, const TreeNodePath &keyPath, std::vector< TreeNode > &nodePath) const |
void | save (const TreeNode &node) |
void | saveAll (const TreeNode &node) |
std::unique_ptr< const TreeNode > | getLinkedNode (const BranchTreeNode &branchNode, size_t index) const |
void | setLink (BranchTreeNode &branchNode, const TreeNode &node, size_t index) |
template<typename TNode > | |
void | setLink (BranchTreeNode &branchNode, const TNode &node, size_t index) |
Static Private Member Functions | |
static std::pair< Hash256, bool > | LookupNotFoundResult () |
Private Attributes | |
TDataSource & | m_dataSource |
TreeNode | m_rootNode |
Represents a compact patricia tree.
using catapult::tree::PatriciaTree< TEncoder, TDataSource >::KeyType = typename TEncoder::KeyType |
using catapult::tree::PatriciaTree< TEncoder, TDataSource >::ValueType = typename TEncoder::ValueType |
|
inlineexplicit |
Creates a tree around a dataSource.
|
inlineprivate |
|
inline |
Clears the tree.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
Tries to find the value associated with key in the tree and stores proof of existence or not in nodePath.
|
inlineprivate |
|
inlinestaticprivate |
|
inline |
Gets the root hash that uniquely identifies this tree.
|
inlineprivate |
|
inline |
Saves all tree nodes to the underlying data source.
|
inlineprivate |
|
inline |
Sets key to value in the tree.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
Sets the root to rootNode.
|
inline |
Loads the node with hash rootHash and sets it as the root node.
|
inline |
Removes the value associated with key from the tree.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
private |
|
private |