refactor the main file

pull/1178/head
Minh Doan 6 years ago committed by Minh Doan
parent 7ec1d260c4
commit 39d5d88e17
  1. 49
      cmd/harmony/main.go

@ -128,6 +128,21 @@ var (
) )
func initSetup() { func initSetup() {
flag.Var(&utils.BootNodes, "bootnodes", "a list of bootnode multiaddress (delimited by ,)")
flag.Parse()
nodeconfig.SetVersion(fmt.Sprintf("Harmony (C) 2018. %v, version %v-%v (%v %v)", path.Base(os.Args[0]), version, commit, builtBy, builtAt))
if *versionFlag {
printVersion()
}
// maybe request passphrase for bls key.
passphraseForBls()
// Configure log parameters
utils.SetLogContext(*port, *ip)
utils.SetLogVerbosity(log.Lvl(*verbosity))
// Add GOMAXPROCS to achieve max performance. // Add GOMAXPROCS to achieve max performance.
runtime.GOMAXPROCS(runtime.NumCPU() * 4) runtime.GOMAXPROCS(runtime.NumCPU() * 4)
@ -165,6 +180,20 @@ func initSetup() {
} }
} }
func passphraseForBls() {
// If FN node running, they should either specify blsPrivateKey or the file with passphrase
if *blsKeyFile == "" || *blsPass == "" {
fmt.Println("Internal nodes need to have pass to decrypt blskey")
os.Exit(101)
}
passphrase, err := utils.GetPassphraseFromSource(*blsPass)
if err != nil {
fmt.Printf("error when reading passphrase file: %v\n", err)
os.Exit(100)
}
blsPassphrase = passphrase
}
func setupECDSAKeys() { func setupECDSAKeys() {
ks = hmykey.GetHmyKeyStore() ks = hmykey.GetHmyKeyStore()
@ -416,26 +445,6 @@ func setUpConsensusAndNode(nodeConfig *nodeconfig.ConfigType) *node.Node {
} }
func main() { func main() {
flag.Var(&utils.BootNodes, "bootnodes", "a list of bootnode multiaddress (delimited by ,)")
flag.Parse()
nodeconfig.SetVersion(fmt.Sprintf("Harmony (C) 2018. %v, version %v-%v (%v %v)", path.Base(os.Args[0]), version, commit, builtBy, builtAt))
if *versionFlag {
printVersion()
}
// If FN node running, they should either specify blsPrivateKey or the file with passphrase
if *blsKeyFile == "" || *blsPass == "" {
fmt.Println("Internal nodes need to have pass to decrypt blskey")
os.Exit(101)
}
passphrase, err := utils.GetPassphraseFromSource(*blsPass)
if err != nil {
fmt.Printf("error when reading passphrase file: %v\n", err)
os.Exit(100)
}
blsPassphrase = passphrase
initSetup() initSetup()
nodeConfig := createGlobalConfig() nodeConfig := createGlobalConfig()

Loading…
Cancel
Save