File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -276,16 +276,6 @@ func (c *Client) GetPeers() []PeerInfo {
276276 return peers
277277}
278278
279- // GetPrivateKeyHex returns the hex-encoded private key for this peer.
280- // This can be saved and used in Config.PrivateKey to maintain the same peer ID across restarts.
281- func (c * Client ) GetPrivateKeyHex () (string , error ) {
282- priv := c .host .Peerstore ().PrivKey (c .host .ID ())
283- if priv == nil {
284- return "" , fmt .Errorf ("private key not found in peerstore" )
285- }
286- return PrivateKeyToHex (priv )
287- }
288-
289279// Close shuts down the client and releases all resources.
290280func (c * Client ) Close () error {
291281 c .cancel ()
@@ -582,3 +572,11 @@ func PrivateKeyFromHex(keyHex string) (crypto.PrivKey, error) {
582572
583573 return priv , nil
584574}
575+
576+ func keyToHex (priv crypto.PrivKey ) string {
577+ keyBytes , err := crypto .MarshalPrivateKey (priv )
578+ if err != nil {
579+ return ""
580+ }
581+ return hex .EncodeToString (keyBytes )
582+ }
You can’t perform that action at this time.
0 commit comments