feat(peerstore) add peer to peerstore upon instantiation
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Dec 8, 2014 at 01:52 UTC
c69f6895db5d8e94b8c3c8e51b3f96b63a2dae1b
1 file changed
+6
-2
peer/peerstore.go
+6
-2
@@ -114,12 +114,16 @@ func (ps *peerstore) WithKeyPair(sk ic.PrivKey, pk ic.PubKey) (Peer, error) {
114
return nil, errors.Errorf("Failed to hash public key: %v", err)
115
}
116
117
- return &peer{id: pkid, pubKey: pk, privKey: sk}, nil
117
+ p := &peer{id: pkid, pubKey: pk, privKey: sk}
118
+ ps.Add(p)
119
+ return p, nil
120
}
121
122
// WithID constructs a peer with given ID.
123
func (ps *peerstore) WithID(id ID) Peer {
122
- return &peer{id: id}
124
+ p := &peer{id: id}
125
+ ps.Add(p)
126
+ return p
127
}
128
129
// WithIDString constructs a peer with given ID (string).