-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.old
38 lines (27 loc) · 1.01 KB
/
main.old
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"
"math/rand"
"time"
"github.com/zohaibadnan137/assignment01bca"
)
func main() {
rand.Seed(time.Now().UnixNano())
fmt.Println("Create a new blockchain...")
blockchain := assignment01bca.CreateBlockchain(2)
fmt.Println("Create three new transactions from Zohaib to Hussain...")
var transactions [3]assignment01bca.Transaction
transactions[0] = assignment01bca.CreateTransaction("Zohaib", "Hussain", 10)
transactions[1] = assignment01bca.CreateTransaction("Zohaib", "Hussain", 15)
transactions[2] = assignment01bca.CreateTransaction("Zohaib", "Hussain", 15)
fmt.Println("Create a new block and add the transactions to it...")
block := assignment01bca.NewBlock(&blockchain, transactions[:])
fmt.Println("Print the transactions added in the new block...")
assignment01bca.DisplayMerkelTree(block)
start := time.Now()
fmt.Println("Mining the block...")
blockchain.MineBlock(&block)
elapsed := time.Since(start)
fmt.Printf("Mining took %s.\n", elapsed)
blockchain.DisplayBlocks()
}