1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 23:42:20 +08:00

return sentinel error for invalid records

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
Jeromy
2015-11-20 11:12:14 -08:00
parent 6b1f1ec1ba
commit 51d031c115
2 changed files with 20 additions and 13 deletions

View File

@ -171,21 +171,26 @@ 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,
})
}
switch err {
case routing.ErrNotFound:
// in this case, they responded with nothing,
// still send a notification so listeners can know the
// request has completed 'successfully'
notif.PublishQueryEvent(parent, &notif.QueryEvent{
Type: notif.PeerResponse,
ID: p,
})
return nil, err
default:
return nil, err
case nil, errInvalidRecord:
// in either of these cases, we want to keep going
}
res := &dhtQueryResult{closerPeers: peers}
if rec.GetValue() != nil {
if rec.GetValue() != nil || err == errInvalidRecord {
rv := routing.RecvdVal{
Val: rec.GetValue(),
From: p,