-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (30 loc) · 865 Bytes
/
main.go
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
package main
import (
"fmt"
"strings"
blockdata "github.com/AviTheBrown/Go_Blockchain/block_data"
)
func askUser() int {
var number int
fmt.Println("Enter how many zeros the hash must start with: ")
fmt.Scan(&number)
fmt.Println()
return number
}
func createZero(count int) string {
return fmt.Sprintf(strings.Repeat("0", count))
}
func main() {
getUserNumber := askUser()
zeros := createZero(getUserNumber)
gensis := blockdata.CreateGenesisBlock(zeros)
gensis.PrintBlockInfo()
secondBlock := blockdata.CreateNewBlock(gensis, 2, zeros)
secondBlock.PrintBlockInfo()
thirdBlock := blockdata.CreateNewBlock(secondBlock, 3, zeros)
thirdBlock.PrintBlockInfo()
fourthBlock := blockdata.CreateNewBlock(thirdBlock, 4, zeros)
fourthBlock.PrintBlockInfo()
fithBlock := blockdata.CreateNewBlock(fourthBlock, 5, zeros)
fithBlock.PrintBlockInfo()
}