@cryptotaxi247 / kubo / commits / 079bdbacd

doc(peer) question

Brian Tiger Chow committed Nov 11, 2014 at 15:12 UTC 079bdbacdfd63cd947b2fb75ece01824af07cfbc
1 file changed +11
peer/peerstore.go
+11
@@ -47,6 +47,17 @@ func (p *peerstore) Get(i ID) (Peer, error) {
47
48 // not found, construct it ourselves, add it to datastore, and return.
49 case ds.ErrNotFound:
50 +
51 + // TODO(brian) kinda dangerous, no? If ID is invalid and doesn't
52 + // correspond to an actual valid peer ID, this peerstore will return an
53 + // instantiated peer value, allowing the error to propagate. It might
54 + // be better to nip this at the bud by returning nil and making the
55 + // client manually add a Peer. To keep the peerstore in control, this
56 + // can even be a peerstore method that performs cursory validation.
57 + //
58 + // Potential bad case: Suppose values arrive from untrusted providers
59 + // in the DHT.
60 +
61 peer := &peer{id: i}
62 if err := p.peers.Put(k, peer); err != nil {
63 return nil, err