LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If the file does not exist, it generates and saves a new NodeKey.
()
| 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. |
| 304 | func (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 |
| 323 | func (cfg BaseConfig) DBDir() string { |
nothing calls this directly
no test coverage detected