forked from hyperledger-archives/burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.go
48 lines (36 loc) · 1.29 KB
/
start.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
package commands
import (
"github.com/hyperledger/burrow/core"
cli "github.com/jawher/mow.cli"
)
func Start(output Output) func(cmd *cli.Cmd) {
return func(cmd *cli.Cmd) {
genesisOpt := cmd.StringOpt("g genesis", "",
"Use the specified genesis JSON file rather than a key in the main config, use - to read from STDIN")
configOpt := cmd.StringOpt("c config", "", "Use the specified burrow config file")
cmd.Spec = "[--config=<config file>] [--genesis=<genesis json file>]"
configOpts := addConfigOptions(cmd)
cmd.Action = func() {
conf, err := obtainBurrowConfig(*configOpt, *genesisOpt)
if err != nil {
output.Fatalf("could not obtain config: %v", err)
}
err = configOpts.configure(conf)
if err != nil {
output.Fatalf("could not update burrow config: %v", err)
}
if conf.ValidatorAddress == nil {
output.Fatalf("could not finalise validator address - please provide one in config or via --validator-address")
}
output.Logf("Using validator address: %s", *conf.ValidatorAddress)
kern, err := core.LoadKernelFromConfig(conf)
if err != nil {
output.Fatalf("could not configure Burrow kernel: %v", err)
}
if err = kern.Boot(); err != nil {
output.Fatalf("could not boot Burrow kernel: %v", err)
}
kern.WaitForShutdown()
}
}
}