Commit 3cfc215b authored by Jeromy's avatar Jeromy

send record fixes to peers who send outdated records

License: MIT
Signed-off-by: default avatarJeromy <jeromyj@gmail.com>
parent f1397e31
......@@ -173,7 +173,9 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
err = dht.verifyRecordOnline(ctx, record)
if err != nil {
log.Info("Received invalid record! (discarded)")
return nil, nil, err
// still return a non-nil record to signify that we received
// a bad record from this peer
record = new(pb.Record)
}
return record, peers, nil
}
......
......@@ -91,7 +91,9 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key key.Key) ([]byte, error) {
var recs [][]byte
for _, v := range vals {
recs = append(recs, v.Val)
if v.Val != nil {
recs = append(recs, v.Val)
}
}
i, err := dht.Selector.BestRecord(key, recs)
......@@ -170,6 +172,14 @@ func (dht *IpfsDHT) GetValues(ctx context.Context, key key.Key, nvals int) ([]ro
rec, peers, err := dht.getValueOrPeers(ctx, p, key)
if err != nil {
if err == routing.ErrNotFound {
// in this case, they responded with nothing,
// still send a notification
notif.PublishQueryEvent(parent, &notif.QueryEvent{
Type: notif.PeerResponse,
ID: p,
})
}
return nil, err
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment