-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validate on local put #165
Conversation
Also, double check the key (should be impossible but the check is cheep).
Review request: @dirkmc |
@@ -177,7 +200,11 @@ func (dht *IpfsDHT) GetValues(ctx context.Context, key string, nvals int) (_ []R | |||
|
|||
// If we have it local, don't bother doing an RPC! | |||
lrec, err := dht.getLocal(key) | |||
if err == nil { | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this if statement include the logic from the one on line 219?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No... that logic is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it seems a little strange
|
||
byt, ok := v.([]byte) | ||
if !ok { | ||
return nil, errors.New("value stored in datastore not []byte") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This not []byte
error and the unmarshal
error below are now going to be logged but the function will return nil
in those cases. Whereas for the case where the key does not match ErrNotFound
will be returned. Should all three cases return ErrNotFound
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Sorry, it should return nil, nil.
…ocal value err is nil in this case
@dirkmc fixed. |
Nice, LGTM |
Also deduplicates some validation code.