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

Function runNode

cmd/cqld/bootstrap.go:43–180  ·  view source on GitHub ↗
(nodeID proto.NodeID, listenAddr string)

Source from the content-addressed store, hash-verified

41)
42
43func runNode(nodeID proto.NodeID, listenAddr string) (err error) {
44 genesis, err := loadGenesis()
45 if err != nil {
46 return
47 }
48
49 var masterKey []byte
50 if !conf.GConf.UseTestMasterKey {
51 // read master key
52 fmt.Print("Type in Master key to continue: ")
53 masterKey, err = terminal.ReadPassword(syscall.Stdin)
54 if err != nil {
55 fmt.Printf("Failed to read Master Key: %v", err)
56 }
57 fmt.Println("")
58 }
59
60 err = kms.InitLocalKeyPair(conf.GConf.PrivateKeyFile, masterKey)
61 if err != nil {
62 log.WithError(err).Error("init local key pair failed")
63 return
64 }
65
66 // init nodes
67 log.WithField("node", nodeID).Info("init peers")
68 _, peers, thisNode, err := initNodePeers(nodeID, conf.GConf.PubKeyStoreFile)
69 if err != nil {
70 log.WithError(err).Error("init nodes and peers failed")
71 return
72 }
73
74 mode := bp.BPMode
75 if wsapiAddr != "" {
76 mode = bp.APINodeMode
77 }
78
79 if mode == bp.APINodeMode {
80 if err = rpc.RegisterNodeToBP(30 * time.Second); err != nil {
81 log.WithError(err).Fatal("register node to BP")
82 return
83 }
84 }
85
86 var server *rpc.Server
87
88 // create server
89 log.WithField("addr", listenAddr).Info("create server")
90 if server, err = createServer(
91 conf.GConf.PrivateKeyFile, conf.GConf.PubKeyStoreFile, masterKey, listenAddr); err != nil {
92 log.WithError(err).Error("create server failed")
93 return
94 }
95
96 // start server
97 go func() {
98 server.Serve()
99 }()
100 defer func() {

Callers 1

mainFunction · 0.85

Calls 15

ServeMethod · 0.95
StopMethod · 0.95
StopMethod · 0.95
RegisterServiceMethod · 0.95
StartMethod · 0.95
StopMethod · 0.95
InitLocalKeyPairFunction · 0.92
WithErrorFunction · 0.92
WithFieldFunction · 0.92
InfoFunction · 0.92
NewDHTServiceFunction · 0.92
ServeFunction · 0.92

Tested by

no test coverage detected