Commit 6b1f1ec1 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 f3f77606
...@@ -173,7 +173,9 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID, ...@@ -173,7 +173,9 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
err = dht.verifyRecordOnline(ctx, record) err = dht.verifyRecordOnline(ctx, record)
if err != nil { if err != nil {
log.Info("Received invalid record! (discarded)") 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 return record, peers, nil
} }
......
...@@ -91,7 +91,9 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key key.Key) ([]byte, error) { ...@@ -91,7 +91,9 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key key.Key) ([]byte, error) {
var recs [][]byte var recs [][]byte
for _, v := range vals { 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) i, err := dht.Selector.BestRecord(key, recs)
...@@ -170,6 +172,14 @@ func (dht *IpfsDHT) GetValues(ctx context.Context, key key.Key, nvals int) ([]ro ...@@ -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) rec, peers, err := dht.getValueOrPeers(ctx, p, key)
if err != nil { 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 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