pub fn load_or_create(data_dir: &Path) -> Result<LoadedKey>Expand description
Load the node’s SecretKey from disk, generating and persisting one if
absent, and report which of the two happened.
Emits no log, so a caller can run it before its tracing subscriber exists
and log LoadedKey::generated itself. The daemon does this so that its
JSON formatter can write node_id on every event.
§Errors
Returns an error if the file exists but is a symlink or other non-regular
file, has the wrong size, or has insecure permissions; if data_dir is
not a directory or has insecure permissions; if the key path can’t be
stat’d for reasons other than non-existence; if the directory cannot be
created; or if reading/writing fails.