Skip to content

Commit 06e7565

Browse files
author
parthendo
committed
initial commit
0 parents  commit 06e7565

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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>

bin/thrain/Block.class

852 Bytes
Binary file not shown.

src/thrain/Block.java

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
}

0 commit comments

Comments
 (0)