Skip to content

Commit beb02be

Browse files
authoredApr 6, 2019
Merge pull request #576 from libp2p/fix/constructor-nits
chore: fail in the libp2p constructor if we fail to store the key
2 parents 12d0f8c + 09d9f0c commit beb02be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎config/config.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
9999
}
100100

101101
if !cfg.Insecure {
102-
cfg.Peerstore.AddPrivKey(pid, cfg.PeerKey)
103-
cfg.Peerstore.AddPubKey(pid, cfg.PeerKey.GetPublic())
102+
if err := cfg.Peerstore.AddPrivKey(pid, cfg.PeerKey); err != nil {
103+
return nil, err
104+
}
105+
if err := cfg.Peerstore.AddPubKey(pid, cfg.PeerKey.GetPublic()); err != nil {
106+
return nil, err
107+
}
104108
}
105109

106110
// TODO: Make the swarm implementation configurable.

0 commit comments

Comments
 (0)
Please sign in to comment.