CatapultServer  v0.5.0.1 (Elephant)
PatriciaTreeContainer.h
Go to the documentation of this file.
1 
21 #pragma once
24 #include "catapult/tree/TreeNode.h"
25 
26 namespace catapult { namespace cache {
27 
30  public:
31  using KeyType = Hash256;
33  using StorageType = std::pair<const KeyType, ValueType>;
34 
35  public:
37  static const auto& GetKeyFromValue(const ValueType& treeNode) {
38  return treeNode.hash();
39  }
40 
42  static auto ToStorage(const ValueType& treeNode) {
43  return StorageType(GetKeyFromValue(treeNode), treeNode.copy());
44  }
45 
47  static const auto& ToKey(const StorageType& element) {
48  return element.first;
49  }
50 
52  static const auto& ToValue(const StorageType& element) {
53  return element.second;
54  }
55 
56  public:
58  };
59 
62 }}
catapult::tree::TreeNode::copy
TreeNode copy() const
Creates a copy of this node.
Definition: TreeNode.cpp:234
catapult::tree::PatriciaTreeSerializer
Serializer for patricia tree.
Definition: PatriciaTreeSerializer.h:27
catapult::cache::PatriciaTreeColumnDescriptor::ToValue
static const auto & ToValue(const StorageType &element)
Converts a storage type (element) to a value type.
Definition: PatriciaTreeContainer.h:52
catapult::cache::PatriciaTreeColumnDescriptor
Patricia tree column descriptor.
Definition: PatriciaTreeContainer.h:29
catapult::Hash256
utils::ByteArray< Hash256_Size, Hash256_tag > Hash256
Definition: src/catapult/types.h:47
RdbTypedColumnContainer.h
catapult::cache::PatriciaTreeColumnDescriptor::GetKeyFromValue
static const auto & GetKeyFromValue(const ValueType &treeNode)
Gets the key corresponding to treeNode.
Definition: PatriciaTreeContainer.h:37
catapult::tree::TreeNode::hash
const Hash256 & hash() const
Gets the hash representation of this node.
Definition: TreeNode.cpp:202
TreeNode.h
catapult::cache::PatriciaTreeColumnDescriptor::ToStorage
static auto ToStorage(const ValueType &treeNode)
Converts a value type (treeNode) to a storage type.
Definition: PatriciaTreeContainer.h:42
catapult::cache::PatriciaTreeColumnDescriptor::StorageType
std::pair< const KeyType, ValueType > StorageType
Definition: PatriciaTreeContainer.h:33
catapult::cache::PatriciaTreeColumnDescriptor::ToKey
static const auto & ToKey(const StorageType &element)
Converts a storage type (element) to a key type.
Definition: PatriciaTreeContainer.h:47
catapult
Definition: AddressExtractionExtension.cpp:28
catapult::tree::TreeNode
Represents a tree node.
Definition: TreeNode.h:124
catapult::utils::ByteArray< Hash256_Size, Hash256_tag >
catapult::cache::RdbTypedColumnContainer< PatriciaTreeColumnDescriptor >
PatriciaTreeSerializer.h