MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / initNode

Function initNode

cmd/cql-minerd/node.go:44–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42)
43
44func initNode() (server *mux.Server, direct *rpc.Server, err error) {
45 var masterKey []byte
46 if !conf.GConf.UseTestMasterKey {
47 // read master key
48 fmt.Print("Type in Master key to continue: ")
49 masterKey, err = terminal.ReadPassword(syscall.Stdin)
50 if err != nil {
51 fmt.Printf("Failed to read Master Key: %v", err)
52 }
53 fmt.Println("")
54 }
55
56 if err = kms.InitLocalKeyPair(conf.GConf.PrivateKeyFile, masterKey); err != nil {
57 log.WithError(err).Error("init local key pair failed")
58 return
59 }
60
61 log.Info("init routes")
62
63 // init kms routing
64 route.InitKMS(conf.GConf.PubKeyStoreFile)
65
66 err = mux.RegisterNodeToBP(30 * time.Second)
67 if err != nil {
68 log.Fatalf("register node to BP failed: %v", err)
69 }
70
71 // init server
72 utils.RemoveAll(conf.GConf.PubKeyStoreFile + "*")
73 if server, err = createServer(
74 conf.GConf.PrivateKeyFile, masterKey, conf.GConf.ListenAddr); err != nil {
75 log.WithError(err).Error("create server failed")
76 return
77 }
78 if direct, err = createDirectServer(
79 conf.GConf.PrivateKeyFile, masterKey, conf.GConf.ListenDirectAddr); err != nil {
80 log.WithError(err).Error("create direct server failed")
81 return
82 }
83
84 return
85}
86
87func createServer(privateKeyPath string, masterKey []byte, listenAddr string) (server *mux.Server, err error) {
88 server = mux.NewServer()

Callers 1

mainFunction · 0.70

Calls 13

InitLocalKeyPairFunction · 0.92
WithErrorFunction · 0.92
InfoFunction · 0.92
InitKMSFunction · 0.92
RegisterNodeToBPFunction · 0.92
FatalfFunction · 0.92
RemoveAllFunction · 0.92
createDirectServerFunction · 0.85
PrintMethod · 0.80
PrintlnMethod · 0.80
ErrorMethod · 0.80
createServerFunction · 0.70

Tested by

no test coverage detected