-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlock.h
40 lines (33 loc) · 877 Bytes
/
Block.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <ctime>
#include <string>
#include <vector>
using namespace std;
// todo: add templating to handle all kinds of data.
// TODO: remove dependence on string.
// VS doesn't highlight 'TODO'. Why the falooda? Going to check out C Lion or whatever it's called by Jetbrains.
struct HashlessBlock
{
int index;
time_t timestamp;
size_t p_hash;
string data;
};
size_t calculate_hash(HashlessBlock * block);
class Block
{
public:
// utter disregard for data encapsulation
int index;
time_t timestamp;
size_t p_hash;
size_t hash;
string data;
static Block * latest_block;
Block(int index, time_t timestamp, size_t p_hash, size_t hash, string data);
~Block();
static Block * get_latest_block();
};
Block * generate_next_block(string data);
Block * get_genesis_block();
bool check_validity_of_new_block(Block * previous_block, Block * new_block);