mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
send record fixes to peers who send outdated records
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -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, ¬if.QueryEvent{
|
||||
Type: notif.PeerResponse,
|
||||
ID: p,
|
||||
})
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user