-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (27 loc) · 697 Bytes
/
main.go
File metadata and controls
33 lines (27 loc) · 697 Bytes
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
package main
import (
"context"
"os"
"simple-consensus-algorithm-impl/blockchain"
"simple-consensus-algorithm-impl/node"
"strconv"
)
func main() {
// ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
// defer cancel()
ctx := context.Background()
// Start the Blockchain
blockchainInstance := blockchain.NewBlockchain()
// Check for Node ID
if len(os.Args) < 1 {
panic("Node ID is required")
}
// Add the node to the network with the given ID
nodeID, err := strconv.ParseInt(os.Args[1], 10, 64)
if err != nil {
panic(err)
}
node.StartNode(nodeID, ctx, blockchainInstance)
// Wait for the main context to be canceled or times out
<-ctx.Done()
}