Bargad v1.0.1 Bargad.Utils View Source

Utility functions required by Bargad.Merkle, Bargad.Log, Bargad.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

Utility function to retrieve the backend module from backend

Utility function for retrieving a tree node

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 in the tree of type tree_node/0

Utility function for persisting a tree node

Helper function to convert a Tuple List into a map

Link to this section Types

Link to this section 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 Bargad.TreeStorage for persisting tree/0 and tree_node/0

Link to this function get_backend_module(backend) View Source

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.

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

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) View Source

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

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

Creates a new tree of type tree/0.

Called by Bargad.Merkle.new/4 when a new Bargad.Map or Bargad.Log has to be created.

Link to this function set_node(tree, key, value) View Source

Utility function for persisting a tree node.

Calls Storage.set_node/3.

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

Helper function to convert a Tuple List into a map.

This is required as Bargad.Trees stores a map as a List of Tuple.