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

Function LoadOrGenNodeKey

types/node_key.go:41–57  ·  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.

(filePath string)

Source from the content-addressed store, hash-verified

39// LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If
40// the file does not exist, it generates and saves a new NodeKey.
41func LoadOrGenNodeKey(filePath string) (NodeKey, error) {
42 if tmos.FileExists(filePath) {
43 nodeKey, err := LoadNodeKey(filePath)
44 if err != nil {
45 return NodeKey{}, err
46 }
47 return nodeKey, nil
48 }
49
50 nodeKey := GenNodeKey()
51
52 if err := nodeKey.SaveAs(filePath); err != nil {
53 return NodeKey{}, err
54 }
55
56 return nodeKey, nil
57}
58
59// GenNodeKey generates a new node key.
60func GenNodeKey() NodeKey {

Callers 6

TestLoadOrGenNodeKeyFunction · 0.92
TestLoadNodeKeyFunction · 0.92
initFilesWithConfigFunction · 0.92
newDefaultNodeFunction · 0.92
NewFunction · 0.92
TestNodeNewSeedNodeFunction · 0.92

Calls 3

LoadNodeKeyFunction · 0.85
GenNodeKeyFunction · 0.85
SaveAsMethod · 0.45

Tested by 3

TestLoadOrGenNodeKeyFunction · 0.74
TestLoadNodeKeyFunction · 0.74
TestNodeNewSeedNodeFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…