sgns::storage::trie::Codec¶
Internal codec for nodes in the Trie. Eth and substrate have different codecs, but rest of the code should be same.
#include <codec.hpp>
Inherits from IComponent
Inherited by sgns::storage::trie::SuperGeniusCodec
Public Functions¶
| Name | |
|---|---|
| ~Codec() override =default | |
| virtual outcome::result< base::Buffer > | encodeNode(const Node & node) const =0 Encode node to byte representation. |
| virtual outcome::result< std::shared_ptr< Node > > | decodeNode(const base::Buffer & encoded_data) const =0 Decode node from bytes. |
| virtual base::Buffer | merkleValue(const base::Buffer & buf) const =0 Get the merkle value of a node. |
| virtual base::Hash256 | hash256(const base::Buffer & buf) const =0 Get the hash of a node. |
Additional inherited members¶
Public Functions inherited from IComponent
| Name | |
|---|---|
| virtual | ~IComponent() =default |
| virtual std::string | GetName() =0 |
Public Functions Documentation¶
function ~Codec¶
function encodeNode¶
Encode node to byte representation.
Parameters:
- node node in the trie
Return: encoded representation of the node
Reimplemented by: sgns::storage::trie::SuperGeniusCodec::encodeNode
function decodeNode¶
virtual outcome::result< std::shared_ptr< Node > > decodeNode(
const base::Buffer & encoded_data
) const =0
Decode node from bytes.
Parameters:
- encoded_data a buffer containing encoded representation of a node
Return: a node in the trie
Reimplemented by: sgns::storage::trie::SuperGeniusCodec::decodeNode
function merkleValue¶
Get the merkle value of a node.
Parameters:
- buf byte representation of the node
Return: hash of the buffer, or the buffer itself if it is shorter than the hash
Reimplemented by: sgns::storage::trie::SuperGeniusCodec::merkleValue
function hash256¶
Get the hash of a node.
Parameters:
- buf byte representation of the node
Return: hash of the buffer
Reimplemented by: sgns::storage::trie::SuperGeniusCodec::hash256
Updated on 2026-03-04 at 13:10:44 -0800