Skip to content

Commit 4de9345

Browse files
#7 Blockchain Creating a Block
1 parent 2159707 commit 4de9345

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/index.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
class Human {
2-
public name: string;
3-
private age: number;
4-
public gender: string;
5-
constructor(name: string, age: number, gender: string) {
6-
this.name = name;
7-
this.age = age;
8-
this.gender = gender;
1+
class Block {
2+
public index: number;
3+
public hash: string;
4+
public previousHash: string;
5+
public data: string;
6+
public timestamp: number;
7+
constructor(
8+
index: number,
9+
hash: string,
10+
previousHash: string,
11+
data: string,
12+
timestamp: number
13+
) {
14+
this.index = index;
15+
this.hash = hash;
16+
this.previousHash = previousHash;
17+
this.data = data;
18+
this.timestamp = timestamp;
919
}
1020
}
1121

12-
const lynn = new Human("Lynn", 18, "female");
22+
const genesisBlock: Block = new Block(0, "2020202020202", "", "Hello", 123456);
1323

14-
const sayHi = (person: Human): string => {
15-
return `Hello ${person.name}, you are ${person.age}, you are a ${
16-
person.gender
17-
}!`;
18-
};
24+
let blockchain: [Block] = [genesisBlock];
1925

20-
console.log(sayHi(lynn));
26+
console.log(blockchain);
2127

2228
export {};

0 commit comments

Comments
 (0)