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

Function getPublicFromConfig

cmd/cql/internal/cfg.go:169–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167}
168
169func getPublicFromConfig() *asymmetric.PublicKey {
170 configFile = utils.HomeDirExpand(configFile)
171
172 var err error
173 // load config
174 if conf.GConf, err = conf.LoadConfig(configFile); err != nil {
175 ConsoleLog.WithError(err).Error("load config file failed")
176 SetExitStatus(1)
177 ExitIfErrors()
178 }
179
180 //if config has public, use it
181 for _, node := range conf.GConf.KnownNodes {
182 if node.ID == conf.GConf.ThisNodeID {
183 if node.PublicKey != nil {
184 ConsoleLog.Infof("use public key in config file: %s", configFile)
185 return node.PublicKey
186 }
187 break
188 }
189 }
190
191 //use config specific private key file(already init by configInit())
192 ConsoleLog.Infof("generate public key directly from private key: %s", conf.GConf.PrivateKeyFile)
193 privateKey, err := kms.LoadPrivateKey(conf.GConf.PrivateKeyFile, []byte(password))
194 if err != nil {
195 ConsoleLog.WithError(err).Error("load private key file failed")
196 SetExitStatus(1)
197 ExitIfErrors()
198 }
199 return privateKey.PubKey()
200}
201
202func storeDSN(dsnArray []string) {
203 dsnFilePath := path.Join(conf.GConf.WorkingRoot, ".dsn")

Callers 1

runIDMinerFunction · 0.85

Calls 9

HomeDirExpandFunction · 0.92
LoadConfigFunction · 0.92
LoadPrivateKeyFunction · 0.92
SetExitStatusFunction · 0.85
ExitIfErrorsFunction · 0.85
ErrorMethod · 0.80
WithErrorMethod · 0.80
InfofMethod · 0.80
PubKeyMethod · 0.80

Tested by

no test coverage detected