-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (32 loc) · 1.01 KB
/
main.cpp
File metadata and controls
43 lines (32 loc) · 1.01 KB
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
41
42
43
#include <iostream>
#include <ctime>
#include <vector>
#include "TransactionData.h"
#include "Block.h"
#include "Blockchain.h"
using namespace std;
int main()
{
// Start Blockchain
Blockchain awesomeCoin;
// Data for first block
time_t dataOneTime;
TransactionData dataOne(1.5, "Joe", "Sally", time(&dataOneTime));
awesomeCoin.addBlock(dataOne);
time_t dataTwoTime;
TransactionData dataTwo(0.2233, "Martha", "Fred", time(&dataTwoTime));
awesomeCoin.addBlock(dataTwo);
// Let's see what's in the awesomeCoin blockchain!
awesomeCoin.printChain();
// Is it valid?
printf("\nIs chain still valid %d\n", awesomeCoin.isChainValid());
// Someone's getting sneaky
Block* hackBlock = awesomeCoin.getLatestBlock();
hackBlock->data.amount = 10000; // Oh yeah!
hackBlock->data.receiverKey = "Jon"; // mwahahahaha!
// Let's look at data
awesomeCoin.printChain();
// Awww! Why is it not valid?
printf("\nIs chain still valid? %d\n", awesomeCoin.isChainValid());
return 0;
}