File tree 3 files changed +53
-0
lines changed
3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <projectDescription >
3
+ <name >thrain</name >
4
+ <comment ></comment >
5
+ <projects >
6
+ </projects >
7
+ <buildSpec >
8
+ <buildCommand >
9
+ <name >org.eclipse.jdt.core.javabuilder</name >
10
+ <arguments >
11
+ </arguments >
12
+ </buildCommand >
13
+ </buildSpec >
14
+ <natures >
15
+ <nature >org.eclipse.jdt.core.javanature</nature >
16
+ </natures >
17
+ </projectDescription >
Original file line number Diff line number Diff line change
1
+ package thrain ;
2
+ import java .util .Arrays ;
3
+
4
+ /*This class is representation of what information shall each block have. The block also generates
5
+ * hash signature based on signature of previous block and the data present in the current block.
6
+ */
7
+
8
+ public class Block {
9
+
10
+ //Previous Hash is the signature of the previous block used to maintain the list
11
+ private int previousHash ;
12
+ //Transaction is the list of transactions we make
13
+ private String [] transactions ;
14
+
15
+ //Hash Previous Hash and transactions to get a new signature of the current block
16
+ //NOTE: The signature changes if any of the parameter of the hashCode function changes
17
+ private int currentBlockHash ;
18
+
19
+ Block (int previousHash , String [] transactions ){
20
+
21
+ this .previousHash = previousHash ;
22
+ this .transactions = transactions ;
23
+
24
+ Object [] value = {Arrays .hashCode (transactions ),previousHash };
25
+ this .currentBlockHash = Arrays .hashCode (value );
26
+ }
27
+
28
+ public int getPreviousHash () {
29
+
30
+ return previousHash ;
31
+ }
32
+
33
+ public String [] getTransaction () {
34
+ return transactions ;
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments