-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (38 loc) · 861 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
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"github.com/seafooler/bdt/config"
"github.com/seafooler/bdt/core"
"time"
)
var conf *config.Config
var err error
func init() {
conf, err = config.LoadConfig("", "config")
if err != nil {
panic(err)
}
}
func main() {
//logger := hclog.New(&hclog.LoggerOptions{
// Name: "bdt-main",
// Output: hclog.DefaultOutput,
// Level: hclog.Level(conf.LogLevel),
//})
node := core.NewNode(conf)
if err = node.StartP2PListen(); err != nil {
panic(err)
}
// wait for each node to start
time.Sleep(time.Second * time.Duration(conf.WaitTime))
if err = node.EstablishP2PConns(); err != nil {
panic(err)
}
// Help all the replicas to start simultaneously
node.BroadcastSyncLaunchMsgs()
node.WaitForEnoughSyncLaunchMsgs()
go node.HandleMsgsLoop()
go node.Bolt.ProposalLoop(0)
for {
time.Sleep(time.Second)
}
}