OlinCoin
Test
blockchain.h
1#pragma once
2
3#include "constants.h"
4#include "uthash.h"
5#include "base_block.h"
6#include "constants.h"
7#include "leveldb/c.h"
8
9typedef struct BlockChain {
10 unsigned char id[BLOCK_HASH_LEN];
11 Block *block;
12 UT_hash_handle hh;
14
15BlockChain *blockchain;
16unsigned char top_block_header_hash[BLOCK_HASH_LEN];
17unsigned long chain_height;
18
19char *blockchain_path;
20leveldb_t *blockchain_db; // Level DB Database
21
22/* Initializes the global blockchain variables */
23int blockchain_init_leveldb(char *db_env);
24
30int destroy_blockchain();
31
38int blockchain_add_leveldb(Block *block);
39
48int blockchain_find_leveldb(Block **found_block, unsigned char *block_hash);
49
56int blockchain_remove_leveldb(unsigned char *block_hash);
57
64int blockchain_count(unsigned int *num_entries);
65
66/*
67Prints the entire blockchain Hashmap to stdout
68
69prefix: string to put in front of all print commands used for tabbing structure
70*/
71void print_blockchain_hashmap(char *prefix);
72void pretty_print_blockchain_hashmap();
73
82int read_top_hash(unsigned char *dest);
83
89int write_top_hash();
90
96int delete_top_hash();
97
103int read_chain();
104
111int write_chain_height();
112
118int delete_chain_height();
Definition: blockchain.h:9
Definition: base_block.h:12