- 通过阅读代码理解Merkle Trees的结构,代码地址C++ implementation of a self balancing merkle tree
主要数据结构
节点Node
#ifndef NODE_H
#define NODE_H
#include <string>
struct Node {
std::string hash;
Node *left;
Node *right;
Node(std::string data);
};
#endif /* NODE_H */
MerkleTree
#ifndef MERKLE_TREE_H
#define MERKLE_TREE_H
#include "node.h"
#include "picosha2.h"
#include "misc.h"
#include <vector>
#include <string>
struct MerkleTree {
Node* root;
MerkleTree(std::vector<Node*> blocks);
~MerkleTree();
void printTree(<