Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Rename Trie.prove to Trie.createProof #122

Merged
merged 4 commits into from Jun 1, 2020
Merged

Conversation

ryanio
Copy link
Contributor

@ryanio ryanio commented May 29, 2020

This PR:

  • Renames prove to createProof
    • Keeps prove as a deprecated alias
  • Introduces type Proof = Buffer[] to improve param types for fromProof, createProof, and verifyProof.

Fixes #120

This PR also tidies up and adds some missing doc comments. In particular @memberof @method and @returns {Promise} are automatically understood so they don't need to be explicitly defined (see Doc Comments syntax).

Copy link
Contributor

@evertonfraga evertonfraga left a comment

Choose a reason for hiding this comment

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

This is a good step in a more semantic API.

I have compared the generated documentation with the former one, and it indeed not seem to require @method and empty @return annotations.

createProof documentation is also 👍 https://github.com/ethereumjs/merkle-patricia-tree/blob/rename-trie-prove/docs/classes/_basetrie_.trie.md#static-createproof

Approved :)

@@ -50,6 +54,7 @@ See the [docs](https://github.com/ethereumjs/merkle-patricia-tree/tree/master/do
- Upgrade ethereumjs-util to 7.0.0 / Upgrade level-mem to 5.0.1 ([#116](https://github.com/ethereumjs/merkle-patricia-tree/pull/116))
- Create dual ES5 and ES2017 builds ([#117](https://github.com/ethereumjs/merkle-patricia-tree/pull/117))
- Include checkpoints by default in SecureTrie.copy ([#119](https://github.com/ethereumjs/merkle-patricia-tree/pull/119))
- Rename Trie.prove to Trie.createProof ([#122](https://github.com/ethereumjs/merkle-patricia-tree/pull/122))
Copy link
Contributor

Choose a reason for hiding this comment

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

Changelog entries. OK

await trie.put(Buffer.from('test'), Buffer.from('one'))
const proof = await Trie.createProof(trie, Buffer.from('test'))
const value = await Trie.verifyProof(trie.root, Buffer.from('test'), proof)
console.log(value.toString()) // 'one'
Copy link
Contributor

Choose a reason for hiding this comment

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

Code example updated 👍

* Commits a checkpoint to disk, if current checkpoint is not nested. If
* nested, only sets the parent checkpoint as current checkpoint.
* @method commit
* @returns {Promise}
Copy link
Contributor

Choose a reason for hiding this comment

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

On this particular function, the @return annotation is gone.

val = await CheckpointTrie.verifyProof(trie.root, Buffer.from('b'), proof)
t.equal(val!.toString('utf8'), 'b')

proof = await CheckpointTrie.prove(trie, Buffer.from('c'))
proof = await CheckpointTrie.createProof(trie, Buffer.from('c'))
val = await CheckpointTrie.verifyProof(trie.root, Buffer.from('c'), proof)
t.equal(val!.toString('utf8'), 'c')

Copy link
Contributor

Choose a reason for hiding this comment

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

Renaming in tests 👍

@@ -5,7 +5,7 @@
"plugin": "typedoc-plugin-markdown",
"readme": "none",
"gitRevision": "master",
"exclude": "src/**/!(secure|checkpointTrie|baseTrie).ts",
"exclude": ["src/**/!(secure|checkpointTrie|baseTrie).ts", "test/**/*.ts"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Yes, looks good to me as well, cool! 😄

@evertonfraga Please drop a note if you explicitly not wanted to give this an "official" approval yet.

@evertonfraga
Copy link
Contributor

@holgerd77 that was an official approval :)

@holgerd77
Copy link
Member

@evertonfraga ah, sorry, just saw the "Approved. :-)" comment. 😛

@evertonfraga evertonfraga merged commit 3ed946a into release/4.0.0 Jun 1, 2020
@evertonfraga evertonfraga deleted the rename-trie-prove branch June 1, 2020 17:01
@ryanio ryanio mentioned this pull request Jun 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants