MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / LoadOrGenNodeKey

Function LoadOrGenNodeKey

p2p/key.go:50–69  ·  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

48// LoadOrGenNodeKey attempts to load the NodeKey from the given filePath. If
49// the file does not exist, it generates and saves a new NodeKey.
50func LoadOrGenNodeKey(filePath string) (*NodeKey, error) {
51 if tmos.FileExists(filePath) {
52 nodeKey, err := LoadNodeKey(filePath)
53 if err != nil {
54 return nil, err
55 }
56 return nodeKey, nil
57 }
58
59 privKey := ed25519.GenPrivKey()
60 nodeKey := &NodeKey{
61 PrivKey: privKey,
62 }
63
64 if err := nodeKey.SaveAs(filePath); err != nil {
65 return nil, err
66 }
67
68 return nodeKey, nil
69}
70
71// LoadNodeKey loads NodeKey located in filePath.
72func LoadNodeKey(filePath string) (*NodeKey, error) {

Callers 10

initFilesWithConfigFunction · 0.92
DefaultNewNodeFunction · 0.92
setupNodeFunction · 0.92
initFilesWithConfigFunction · 0.92
genNodeKeyFunction · 0.92
NewTendermintFunction · 0.92
DefaultNewNodeFunction · 0.92
TestLoadOrGenNodeKeyFunction · 0.85
TestLoadNodeKeyFunction · 0.85

Calls 3

SaveAsMethod · 0.95
GenPrivKeyFunction · 0.92
LoadNodeKeyFunction · 0.85

Tested by 3

TestLoadOrGenNodeKeyFunction · 0.68
TestLoadNodeKeyFunction · 0.68