csmt v1.0.0 CSMT.Utils

Utility functions required by CSMT.Merkle, CSMT.Log, CSMT.Map.

Link to this section Summary

Functions

Decodes a binary into a tree_node/0 using exprotobuf

Decodes a binary into a tree/0 using exprotobuf

Encodes tree_node/0 into a binary using exprotobuf

Encodes tree/0 into a binary using exprotobuf

Generates a unique TreeId for every tree. This TreeId is used by Storage and CSMT.TreeStorage for persisting tree/0 and tree_node/0

Utility function to retrieve the backend module from backend

Utility function for retrieving a tree node. Calls Storage.get_node/2

Hashes the binary data supplied based on the hash algorithm hash_algorithm/0 specified in t:tree

Creates an inner node in the tree of type tree_node/0. Creates a new node with its children as left and right

Creates a new node in the tree of type tree_node/0

Creates a new tree of type tree/0. Called by CSMT.Merkle.new/4 when a new CSMT.Map or CSMT.Log has to be created

Utility function for persisting a tree node. Calls Storage.set_node/3

Helper function to convert a Tuple List into a map. This is required as CSMT.Trees stores a map as a List of Tuple

Link to this section Types

Link to this type backend()
backend() :: CSMT.Types.backend()
Link to this type hash_algorithm()
hash_algorithm() :: CSMT.Types.hash_algorithm()
Link to this type tree_node()
tree_node() :: CSMT.Types.tree_node()

Link to this section Functions

Link to this function decode_node(node)

Decodes a binary into a tree_node/0 using exprotobuf.

Link to this function decode_tree(tree)

Decodes a binary into a tree/0 using exprotobuf.

Link to this function delete_node(tree, key)
Link to this function encode_node(node)

Encodes tree_node/0 into a binary using exprotobuf.

Link to this function encode_tree(tree)

Encodes tree/0 into a binary using exprotobuf.

Link to this function generate_tree_id()

Generates a unique TreeId for every tree. This TreeId is used by Storage and CSMT.TreeStorage for persisting tree/0 and tree_node/0

Link to this function get_backend_module(backend)

Utility function to retrieve the backend module from backend.

Link to this function get_node(tree, key)

Utility function for retrieving a tree node. Calls Storage.get_node/2.

Link to this function make_hash(tree, data)

Hashes the binary data supplied based on the hash algorithm hash_algorithm/0 specified in t:tree.

Link to this function make_map_node(tree, left, right)
Link to this function make_node(tree, left, right)

Creates an inner node in the tree of type tree_node/0. Creates a new node with its children as left and right.

Link to this function make_node(tree, hash, children, size, metadata)

Creates a new node in the tree of type tree_node/0.

Link to this function make_tree(tree_name, hash_function, backend)
make_tree(binary(), hash_algorithm(), backend()) :: tree()

Creates a new tree of type tree/0. Called by CSMT.Merkle.new/4 when a new CSMT.Map or CSMT.Log has to be created.

Link to this function salt_node(k, v)
Link to this function set_node(tree, key, value)

Utility function for persisting a tree node. Calls Storage.set_node/3.

Link to this function tuple_list_to_map(tpl)
tuple_list_to_map(tuple()) :: map()

Helper function to convert a Tuple List into a map. This is required as CSMT.Trees stores a map as a List of Tuple.