Skip to content
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

Merged
merged 6 commits into from
Jun 14, 2018
Merged

validate on local put #165

merged 6 commits into from
Jun 14, 2018

Conversation

Stebalien
Copy link
Member

Also deduplicates some validation code.

@Stebalien
Copy link
Member Author

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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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")
Copy link
Contributor

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?

Copy link
Member Author

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.

@Stebalien
Copy link
Member Author

@dirkmc fixed.

@dirkmc
Copy link
Contributor

dirkmc commented Jun 14, 2018

Nice, LGTM

@Stebalien Stebalien merged commit 240a27a into master Jun 14, 2018
@ghost ghost removed the status/in-progress In progress label Jun 14, 2018
@whyrusleeping whyrusleeping deleted the feat/better-validation branch June 15, 2018 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants