-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlock.java
More file actions
34 lines (24 loc) · 800 Bytes
/
Block.java
File metadata and controls
34 lines (24 loc) · 800 Bytes
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
import java.util.Arrays;
public class Block {
private int previousHash;
private String[] transactions;
private int blockHash;
public Block (int previousHash, String[] transactions) {
this.previousHash = previousHash;
this.transactions = transactions;
//this.blockHash = calculateHash();
//If I change anything in the previous block, those changes
//will be reflected in the current block.
Object[] contents = {Arrays.hashCode(transactions)};
this.blockHash = Arrays.hashCode(contents);
}
public int getPreviousHash() {
return previousHash;
}
public String[] getTransactions() {
return transactions;
}
public int getBlockHash() {
return blockHash;
}
}