Fixed docs in code / readme for proof object
The `getProof` function stated that it returned an array of `Buffer`, but it in fact returns an array of a proof object, which looks like this: ``` { position: string, // left or right data: Buffer } ```
This commit is contained in:
parent
609049c974
commit
4680587354
14
README.md
14
README.md
|
@ -55,7 +55,7 @@ npm install merkletreejs
|
||||||
* [.getLeaves()](#MerkleTree+getLeaves) ⇒ <code>Array.<Buffer></code>
|
* [.getLeaves()](#MerkleTree+getLeaves) ⇒ <code>Array.<Buffer></code>
|
||||||
* [.getLayers()](#MerkleTree+getLayers) ⇒ <code>Array.<Buffer></code>
|
* [.getLayers()](#MerkleTree+getLayers) ⇒ <code>Array.<Buffer></code>
|
||||||
* [.getRoot()](#MerkleTree+getRoot) ⇒ <code>Buffer</code>
|
* [.getRoot()](#MerkleTree+getRoot) ⇒ <code>Buffer</code>
|
||||||
* [.getProof(leaf, [index])](#MerkleTree+getProof) ⇒ <code>Array.<Buffer></code>
|
* [.getProof(leaf, [index])](#MerkleTree+getProof) ⇒ <code>Array.<Object></code>
|
||||||
* [.verify(proof, targetNode, root)](#MerkleTree+verify) ⇒ <code>Boolean</code>
|
* [.verify(proof, targetNode, root)](#MerkleTree+verify) ⇒ <code>Boolean</code>
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,11 +134,11 @@ const root = tree.getRoot()
|
||||||
|
|
||||||
<a name="MerkleTree+getProof"></a>
|
<a name="MerkleTree+getProof"></a>
|
||||||
|
|
||||||
### merkleTree.getProof(leaf, [index]) ⇒ <code>Array.<Buffer></code>
|
### merkleTree.getProof(leaf, [index]) ⇒ <code>Array.<Object></code>
|
||||||
Returns the proof for a target leaf.
|
Returns the proof for a target leaf.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>MerkleTree</code>](#MerkleTree)
|
**Kind**: instance method of [<code>MerkleTree</code>](#MerkleTree)
|
||||||
**Returns**: <code>Array.<Buffer></code> - - Array of Buffer hashes.
|
**Returns**: <code>Array.<Object></code> - - Array of objects containing a position property of type string with values of 'left' or 'right' and a data property of type Buffer.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
@ -168,7 +168,7 @@ to the Merkle root.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| proof | <code>Array.<Buffer></code> | Array of proof Buffer hashes that should connect target node to Merkle root. |
|
| proof | <code>Array.<Object></code> | Array of proof objects that should connect target node to Merkle root. |
|
||||||
| targetNode | <code>Buffer</code> | Target node Buffer |
|
| targetNode | <code>Buffer</code> | Target node Buffer |
|
||||||
| root | <code>Buffer</code> | Merkle root Buffer |
|
| root | <code>Buffer</code> | Merkle root Buffer |
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ Class reprensenting a Merkle Tree
|
||||||
* [.getLeaves()](#MerkleTree+getLeaves) ⇒ <code>Array.<Buffer></code>
|
* [.getLeaves()](#MerkleTree+getLeaves) ⇒ <code>Array.<Buffer></code>
|
||||||
* [.getLayers()](#MerkleTree+getLayers) ⇒ <code>Array.<Buffer></code>
|
* [.getLayers()](#MerkleTree+getLayers) ⇒ <code>Array.<Buffer></code>
|
||||||
* [.getRoot()](#MerkleTree+getRoot) ⇒ <code>Buffer</code>
|
* [.getRoot()](#MerkleTree+getRoot) ⇒ <code>Buffer</code>
|
||||||
* [.getProof(leaf, [index])](#MerkleTree+getProof) ⇒ <code>Array.<Buffer></code>
|
* [.getProof(leaf, [index])](#MerkleTree+getProof) ⇒ <code>Array.<Object></code>
|
||||||
* [.verify(proof, targetNode, root)](#MerkleTree+verify) ⇒ <code>Boolean</code>
|
* [.verify(proof, targetNode, root)](#MerkleTree+verify) ⇒ <code>Boolean</code>
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,11 +272,11 @@ const root = tree.getRoot()
|
||||||
|
|
||||||
<a name="MerkleTree+getProof"></a>
|
<a name="MerkleTree+getProof"></a>
|
||||||
|
|
||||||
### merkleTree.getProof(leaf, [index]) ⇒ <code>Array.<Buffer></code>
|
### merkleTree.getProof(leaf, [index]) ⇒ <code>Array.<Object></code>
|
||||||
Returns the proof for a target leaf.
|
Returns the proof for a target leaf.
|
||||||
|
|
||||||
**Kind**: instance method of [<code>MerkleTree</code>](#MerkleTree)
|
**Kind**: instance method of [<code>MerkleTree</code>](#MerkleTree)
|
||||||
**Returns**: <code>Array.<Buffer></code> - - Array of Buffer hashes.
|
**Returns**: <code>Array.<Buffer></code> - - Array of objects containing a position property of type string with values of 'left' or 'right' and a data property of type Buffer.
|
||||||
|
|
||||||
| Param | Type | Description |
|
| Param | Type | Description |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
|
|
5
index.js
5
index.js
|
@ -127,7 +127,8 @@ class MerkleTree {
|
||||||
* @param {Buffer} leaf - Target leaf
|
* @param {Buffer} leaf - Target leaf
|
||||||
* @param {Number} [index] - Target leaf index in leaves array.
|
* @param {Number} [index] - Target leaf index in leaves array.
|
||||||
* Use if there are leaves containing duplicate data in order to distinguish it.
|
* Use if there are leaves containing duplicate data in order to distinguish it.
|
||||||
* @return {Buffer[]} - Array of Buffer hashes.
|
* @return {Object[]} - Array of objects containing a position property of type string
|
||||||
|
* with values of 'left' or 'right' and a data property of type Buffer.
|
||||||
* @example
|
* @example
|
||||||
* const proof = tree.getProof(leaves[2])
|
* const proof = tree.getProof(leaves[2])
|
||||||
*
|
*
|
||||||
|
@ -206,7 +207,7 @@ class MerkleTree {
|
||||||
* verify
|
* verify
|
||||||
* @desc Returns true if the proof path (array of hashes) can connect the target node
|
* @desc Returns true if the proof path (array of hashes) can connect the target node
|
||||||
* to the Merkle root.
|
* to the Merkle root.
|
||||||
* @param {Buffer[]} proof - Array of proof Buffer hashes that should connect
|
* @param {Object[]} proof - Array of proof objects that should connect
|
||||||
* target node to Merkle root.
|
* target node to Merkle root.
|
||||||
* @param {Buffer} targetNode - Target node Buffer
|
* @param {Buffer} targetNode - Target node Buffer
|
||||||
* @param {Buffer} root - Merkle root Buffer
|
* @param {Buffer} root - Merkle root Buffer
|
||||||
|
|
Loading…
Reference in New Issue