Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 81645b9

Browse files
committedNov 19, 2015
send record fixes to peers who send outdated records
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
1 parent 5f8cfc9 commit 81645b9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed
 

‎routing/dht/dht.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.ID,
173173
err = dht.verifyRecordOnline(ctx, record)
174174
if err != nil {
175175
log.Info("Received invalid record! (discarded)")
176-
return nil, nil, err
176+
// still return a non-nil record to signify that we received
177+
// a bad record from this peer
178+
record = new(pb.Record)
177179
}
178180
return record, peers, nil
179181
}

‎routing/dht/routing.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key key.Key) ([]byte, error) {
9191

9292
var recs [][]byte
9393
for _, v := range vals {
94-
recs = append(recs, v.Val)
94+
if v.Val != nil {
95+
recs = append(recs, v.Val)
96+
}
9597
}
9698

9799
i, err := dht.Selector.BestRecord(key, recs)
@@ -170,6 +172,14 @@ func (dht *IpfsDHT) GetValues(ctx context.Context, key key.Key, nvals int) ([]ro
170172

171173
rec, peers, err := dht.getValueOrPeers(ctx, p, key)
172174
if err != nil {
175+
if err == routing.ErrNotFound {
176+
// in this case, they responded with nothing,
177+
// still send a notification
178+
notif.PublishQueryEvent(parent, &notif.QueryEvent{
179+
Type: notif.PeerResponse,
180+
ID: p,
181+
})
182+
}
173183
return nil, err
174184
}
175185

0 commit comments

Comments
 (0)
Please sign in to comment.