Merge pull request #576 from libp2p/fix/constructor-nits
chore: fail in the libp2p constructor if we fail to store the key
This commit is contained in:
commit
beb02be512
|
@ -99,8 +99,12 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
|
|||
}
|
||||
|
||||
if !cfg.Insecure {
|
||||
cfg.Peerstore.AddPrivKey(pid, cfg.PeerKey)
|
||||
cfg.Peerstore.AddPubKey(pid, cfg.PeerKey.GetPublic())
|
||||
if err := cfg.Peerstore.AddPrivKey(pid, cfg.PeerKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := cfg.Peerstore.AddPubKey(pid, cfg.PeerKey.GetPublic()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Make the swarm implementation configurable.
|
||||
|
|
Loading…
Reference in New Issue