MCPcopy Create free account
hub / github.com/tendermint/tendermint / LoadOrGenNodeKeyID

Method LoadOrGenNodeKeyID

config/config.go:304–320  ·  view source on GitHub ↗

LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If the file does not exist, it generates and saves a new NodeKey.

()

Source from the content-addressed store, hash-verified

302// LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If
303// the file does not exist, it generates and saves a new NodeKey.
304func (cfg BaseConfig) LoadOrGenNodeKeyID() (types.NodeID, error) {
305 if tmos.FileExists(cfg.NodeKeyFile()) {
306 nodeKey, err := cfg.LoadNodeKeyID()
307 if err != nil {
308 return "", err
309 }
310 return nodeKey, nil
311 }
312
313 nodeKey := types.GenNodeKey()
314
315 if err := nodeKey.SaveAs(cfg.NodeKeyFile()); err != nil {
316 return "", err
317 }
318
319 return nodeKey.ID, nil
320}
321
322// DBDir returns the full path to the database directory
323func (cfg BaseConfig) DBDir() string {

Callers

nothing calls this directly

Calls 4

NodeKeyFileMethod · 0.95
LoadNodeKeyIDMethod · 0.95
GenNodeKeyFunction · 0.92
SaveAsMethod · 0.45

Tested by

no test coverage detected