-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlock.cpp
55 lines (44 loc) · 1.23 KB
/
Block.cpp
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
44
45
46
47
48
49
50
51
52
53
54
55
#include "Block.h"
Block::Block() {
this->currentHash = "";
this->previousHash = "";
this->input = "";
this->proposedTransactions = nullptr;
}
Block::Block(string currentHash, string input, Transaction* transactions) {
this->currentHash = currentHash;
this->input = input;
this->proposedTransactions = transactions;
}
string Block::getCurrentHash() {
return this->currentHash;
}
void Block::setCurrentHash(string currentHash) {
this->currentHash = currentHash;
}
string Block::getPreviousHash() {
return this->previousHash;
}
void Block::setPreviousHash(string previousHash) {
this->previousHash = previousHash;
}
void Block::addTransactionsToBlock() {
for (int i = 0; i < MAX_TRANSACTIONS_PER_BLOCK; i++) {
auto transaction = this->proposedTransactions[i];
string hash = sha256(transaction.toString());
transaction.setTransactionHash(hash);
this->transactions.insert(pair<string, Transaction>(hash, transaction));
}
}
string Block::getInput() {
return this->input;
}
Transaction* Block::getProposedTransactions() {
return this->proposedTransactions;
}
void Block::setProposedTransactions(Transaction* transactions) {
this->proposedTransactions = transactions;
}
void Block::setInput(string input) {
this->input = input;
}