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

feat: add records validator #5

Merged
merged 2 commits into from
Sep 6, 2018
Merged

Conversation

vasco-santos
Copy link
Member

ipns should offer a validator capable of validate records, as well select which one is the best record between two of them (using the sequence number).

This is particularly useful for validating libp2p records transparently, providing this validator.

Note: go-ipns also provides this feature here

@ghost ghost assigned vasco-santos Sep 6, 2018
@ghost ghost added the status/in-progress In progress label Sep 6, 2018
README.md Outdated

The `validate` function aims to verify if an IPNS record is valid. First the record is unmarshalled, then the public key is obtained and finally the record is validated (signature and validity are verified).

The `select` function is responsible for deciding which ipns record is the best (newer) between two records. Both records are unmarshalled and their sequece numbers are compared. If the first record provided is the newer, the operation result will be `0`, otherwise the operation result will be `1`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

"Both records are unmarshalled and their sequence numbers are compared."

})
})

it('should use validator.select to select the newer record returning 0 if it is the first parameter', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'should use validator.select to select the first record because it is newer'?

})
})

it('should use validator.select to select the newer record returning 1 if it is the second parameter', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same logic as above.

@vasco-santos vasco-santos merged commit 34468e1 into master Sep 6, 2018
@vasco-santos vasco-santos deleted the feat/add-records-validator branch September 6, 2018 16:26
@ghost ghost removed the status/in-progress In progress label Sep 6, 2018
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