cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBMerkleNode/CBMerkleNode.h File Reference

A structure for a node in a merkle tree. More...

#include "CBByteArray.h"
#include "CBDependencies.h"

Go to the source code of this file.

Data Structures

struct  CBMerkleNode

Typedefs

typedef struct CBMerkleNode CBMerkleNode

Functions

CBMerkleNodeCBBuildMerkleTree (CBByteArray **hashes, uint32_t numHashes)
 Builds a Merkle tree from a list of hashes. In cases of duplication, "left" and "right" may refer to the same node.
void CBFreeMerkleTree (CBMerkleNode *root)
 Frees a merkle tree from a given root.
CBMerkleNodeCBMerkleTreeGetLevel (CBMerkleNode *root, uint8_t level)
 Gets a list of hashes for a level in a merkle tree. If the merkle tree's deepest level is smaller than specified by "level", the lowest level in the tree is returned.

Detailed Description

A structure for a node in a merkle tree.


Function Documentation

CBMerkleNode* CBBuildMerkleTree ( CBByteArray **  hashes,
uint32_t  numHashes 
)

Builds a Merkle tree from a list of hashes. In cases of duplication, "left" and "right" may refer to the same node.

Parameters:
hashesA list of hashes as CBByteArrays to build the tree from.
numHashesThe number of hashes.
Returns:
The root CBMerkleNode for the tree.
void CBFreeMerkleTree ( CBMerkleNode root)

Frees a merkle tree from a given root.

Parameters:
rootThe merkle tree root node.
CBMerkleNode* CBMerkleTreeGetLevel ( CBMerkleNode root,
uint8_t  level 
)

Gets a list of hashes for a level in a merkle tree. If the merkle tree's deepest level is smaller than specified by "level", the lowest level in the tree is returned.

Parameters:
rootThe merkle tree root node.
levelThe level to retrieve. Pass in a high number (use 255) to get the deepest level. Level 0 corresponds to the root which was passed in.
Returns:
With nodes left to right, the memory block for this level of the merkle tree.