提交 c69f6895 作者: Brian Tiger Chow

feat(peerstore) add peer to peerstore upon instantiation

License: MIT
Signed-off-by: 's avatarBrian Tiger Chow <brian@perfmode.com>
上级 d77c4bb5
......@@ -114,12 +114,16 @@ func (ps *peerstore) WithKeyPair(sk ic.PrivKey, pk ic.PubKey) (Peer, error) {
return nil, errors.Errorf("Failed to hash public key: %v", err)
}
return &peer{id: pkid, pubKey: pk, privKey: sk}, nil
p := &peer{id: pkid, pubKey: pk, privKey: sk}
ps.Add(p)
return p, nil
}
// WithID constructs a peer with given ID.
func (ps *peerstore) WithID(id ID) Peer {
return &peer{id: id}
p := &peer{id: id}
ps.Add(p)
return p
}
// WithIDString constructs a peer with given ID (string).
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论