fix getLocal error handling

This commit is contained in:
Steven Allen 2018-06-13 19:42:26 -07:00
parent 95067a1cc4
commit 277f253733
2 changed files with 3 additions and 1 deletions

2
dht.go
View File

@ -236,7 +236,7 @@ func (dht *IpfsDHT) getLocal(key string) (*recpb.Record, error) {
// Double check the key. Can't hurt.
if rec != nil && rec.GetKey() != key {
log.Errorf("BUG: found a DHT record that didn't match it's key: %s != %s", rec.GetKey(), key)
return nil, routing.ErrNotFound
return nil, nil
}
return rec, nil

View File

@ -217,6 +217,8 @@ func (dht *IpfsDHT) handlePutValue(ctx context.Context, p peer.ID, pmes *pb.Mess
return pmes, err
}
// returns nil, nil when either nothing is found or the value found doesn't properly validate.
// returns nil, some_error when there's a *datastore* error (i.e., something goes very wrong)
func (dht *IpfsDHT) getRecordFromDatastore(dskey ds.Key) (*recpb.Record, error) {
reci, err := dht.datastore.Get(dskey)
if err == ds.ErrNotFound {