rename concatFn to concatenator
This commit is contained in:
parent
bc5ffc9f0b
commit
c330fe25ff
|
@ -18,15 +18,18 @@
|
|||
* [_isHexString](_src_base_.base.md#protected-_ishexstring)
|
||||
* [_log2](_src_base_.base.md#protected-_log2)
|
||||
* [_zip](_src_base_.base.md#protected-_zip)
|
||||
* [bigNumberify](_src_base_.base.md#bignumberify)
|
||||
* [binarySearch](_src_base_.base.md#binarysearch)
|
||||
* [bufferToHex](_src_base_.base.md#buffertohex)
|
||||
* [bufferify](_src_base_.base.md#bufferify)
|
||||
* [bufferifyFn](_src_base_.base.md#bufferifyfn)
|
||||
* [linearSearch](_src_base_.base.md#linearsearch)
|
||||
* [print](_src_base_.base.md#print)
|
||||
* [bigNumberify](_src_base_.base.md#static-bignumberify)
|
||||
* [binarySearch](_src_base_.base.md#static-binarysearch)
|
||||
* [bufferToHex](_src_base_.base.md#static-buffertohex)
|
||||
* [bufferify](_src_base_.base.md#static-bufferify)
|
||||
* [hexZeroPad](_src_base_.base.md#static-hexzeropad)
|
||||
* [isHexString](_src_base_.base.md#static-ishexstring)
|
||||
* [linearSearch](_src_base_.base.md#static-linearsearch)
|
||||
* [print](_src_base_.base.md#static-print)
|
||||
|
@ -126,6 +129,20 @@ Name | Type | Description |
|
|||
|
||||
___
|
||||
|
||||
### bigNumberify
|
||||
|
||||
▸ **bigNumberify**(`value`: any): *BigInt*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`value` | any |
|
||||
|
||||
**Returns:** *BigInt*
|
||||
|
||||
___
|
||||
|
||||
### binarySearch
|
||||
|
||||
▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number*
|
||||
|
@ -293,6 +310,20 @@ tree.print()
|
|||
|
||||
___
|
||||
|
||||
### `Static` bigNumberify
|
||||
|
||||
▸ **bigNumberify**(`value`: any): *BigInt*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`value` | any |
|
||||
|
||||
**Returns:** *BigInt*
|
||||
|
||||
___
|
||||
|
||||
### `Static` binarySearch
|
||||
|
||||
▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number*
|
||||
|
@ -380,6 +411,21 @@ Name | Type |
|
|||
|
||||
___
|
||||
|
||||
### `Static` hexZeroPad
|
||||
|
||||
▸ **hexZeroPad**(`hexStr`: string, `length`: number): *string*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`hexStr` | string |
|
||||
`length` | number |
|
||||
|
||||
**Returns:** *string*
|
||||
|
||||
___
|
||||
|
||||
### `Static` isHexString
|
||||
|
||||
▸ **isHexString**(`v`: string): *boolean*
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
* [_log2](_src_merklemountainrange_.merklemountainrange.md#protected-_log2)
|
||||
* [_zip](_src_merklemountainrange_.merklemountainrange.md#protected-_zip)
|
||||
* [append](_src_merklemountainrange_.merklemountainrange.md#append)
|
||||
* [bigNumberify](_src_merklemountainrange_.merklemountainrange.md#bignumberify)
|
||||
* [binarySearch](_src_merklemountainrange_.merklemountainrange.md#binarysearch)
|
||||
* [bufferToHex](_src_merklemountainrange_.merklemountainrange.md#buffertohex)
|
||||
* [bufferify](_src_merklemountainrange_.merklemountainrange.md#bufferify)
|
||||
|
@ -61,9 +62,11 @@
|
|||
* [print](_src_merklemountainrange_.merklemountainrange.md#print)
|
||||
* [rollUp](_src_merklemountainrange_.merklemountainrange.md#rollup)
|
||||
* [verify](_src_merklemountainrange_.merklemountainrange.md#verify)
|
||||
* [bigNumberify](_src_merklemountainrange_.merklemountainrange.md#static-bignumberify)
|
||||
* [binarySearch](_src_merklemountainrange_.merklemountainrange.md#static-binarysearch)
|
||||
* [bufferToHex](_src_merklemountainrange_.merklemountainrange.md#static-buffertohex)
|
||||
* [bufferify](_src_merklemountainrange_.merklemountainrange.md#static-bufferify)
|
||||
* [hexZeroPad](_src_merklemountainrange_.merklemountainrange.md#static-hexzeropad)
|
||||
* [isHexString](_src_merklemountainrange_.merklemountainrange.md#static-ishexstring)
|
||||
* [linearSearch](_src_merklemountainrange_.merklemountainrange.md#static-linearsearch)
|
||||
* [print](_src_merklemountainrange_.merklemountainrange.md#static-print)
|
||||
|
@ -254,6 +257,22 @@ Name | Type |
|
|||
|
||||
___
|
||||
|
||||
### bigNumberify
|
||||
|
||||
▸ **bigNumberify**(`value`: any): *BigInt*
|
||||
|
||||
*Inherited from [Base](_src_base_.base.md).[bigNumberify](_src_base_.base.md#bignumberify)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`value` | any |
|
||||
|
||||
**Returns:** *BigInt*
|
||||
|
||||
___
|
||||
|
||||
### binarySearch
|
||||
|
||||
▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number*
|
||||
|
@ -760,6 +779,22 @@ Name | Type |
|
|||
|
||||
___
|
||||
|
||||
### `Static` bigNumberify
|
||||
|
||||
▸ **bigNumberify**(`value`: any): *BigInt*
|
||||
|
||||
*Inherited from [Base](_src_base_.base.md).[bigNumberify](_src_base_.base.md#bignumberify)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`value` | any |
|
||||
|
||||
**Returns:** *BigInt*
|
||||
|
||||
___
|
||||
|
||||
### `Static` binarySearch
|
||||
|
||||
▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number*
|
||||
|
@ -853,6 +888,23 @@ Name | Type |
|
|||
|
||||
___
|
||||
|
||||
### `Static` hexZeroPad
|
||||
|
||||
▸ **hexZeroPad**(`hexStr`: string, `length`: number): *string*
|
||||
|
||||
*Inherited from [Base](_src_base_.base.md).[hexZeroPad](_src_base_.base.md#static-hexzeropad)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`hexStr` | string |
|
||||
`length` | number |
|
||||
|
||||
**Returns:** *string*
|
||||
|
||||
___
|
||||
|
||||
### `Static` isHexString
|
||||
|
||||
▸ **isHexString**(`v`: string): *boolean*
|
||||
|
|
|
@ -27,10 +27,12 @@ Class reprensenting a Merkle Tree
|
|||
* [_zip](_src_merkletree_.merkletree.md#protected-_zip)
|
||||
* [addLeaf](_src_merkletree_.merkletree.md#addleaf)
|
||||
* [addLeaves](_src_merkletree_.merkletree.md#addleaves)
|
||||
* [bigNumberify](_src_merkletree_.merkletree.md#bignumberify)
|
||||
* [binarySearch](_src_merkletree_.merkletree.md#binarysearch)
|
||||
* [bufferToHex](_src_merkletree_.merkletree.md#buffertohex)
|
||||
* [bufferify](_src_merkletree_.merkletree.md#bufferify)
|
||||
* [bufferifyFn](_src_merkletree_.merkletree.md#bufferifyfn)
|
||||
* [combineHashes](_src_merkletree_.merkletree.md#combinehashes)
|
||||
* [getDepth](_src_merkletree_.merkletree.md#getdepth)
|
||||
* [getHexLayers](_src_merkletree_.merkletree.md#gethexlayers)
|
||||
* [getHexLayersFlat](_src_merkletree_.merkletree.md#gethexlayersflat)
|
||||
|
@ -64,10 +66,12 @@ Class reprensenting a Merkle Tree
|
|||
* [verify](_src_merkletree_.merkletree.md#verify)
|
||||
* [verifyMultiProof](_src_merkletree_.merkletree.md#verifymultiproof)
|
||||
* [verifyMultiProofWithFlags](_src_merkletree_.merkletree.md#verifymultiproofwithflags)
|
||||
* [bigNumberify](_src_merkletree_.merkletree.md#static-bignumberify)
|
||||
* [binarySearch](_src_merkletree_.merkletree.md#static-binarysearch)
|
||||
* [bufferToHex](_src_merkletree_.merkletree.md#static-buffertohex)
|
||||
* [bufferify](_src_merkletree_.merkletree.md#static-bufferify)
|
||||
* [getMultiProof](_src_merkletree_.merkletree.md#static-getmultiproof)
|
||||
* [hexZeroPad](_src_merkletree_.merkletree.md#static-hexzeropad)
|
||||
* [isHexString](_src_merkletree_.merkletree.md#static-ishexstring)
|
||||
* [linearSearch](_src_merkletree_.merkletree.md#static-linearsearch)
|
||||
* [marshalLeaves](_src_merkletree_.merkletree.md#static-marshalleaves)
|
||||
|
@ -282,6 +286,22 @@ Name | Type | Default |
|
|||
|
||||
___
|
||||
|
||||
### bigNumberify
|
||||
|
||||
▸ **bigNumberify**(`value`: any): *BigInt*
|
||||
|
||||
*Inherited from [Base](_src_base_.base.md).[bigNumberify](_src_base_.base.md#bignumberify)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`value` | any |
|
||||
|
||||
**Returns:** *BigInt*
|
||||
|
||||
___
|
||||
|
||||
### binarySearch
|
||||
|
||||
▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number*
|
||||
|
@ -400,6 +420,20 @@ Name | Type |
|
|||
|
||||
___
|
||||
|
||||
### combineHashes
|
||||
|
||||
▸ **combineHashes**(`hashes`: Buffer[]): *any*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`hashes` | Buffer[] |
|
||||
|
||||
**Returns:** *any*
|
||||
|
||||
___
|
||||
|
||||
### getDepth
|
||||
|
||||
▸ **getDepth**(): *number*
|
||||
|
@ -1141,6 +1175,22 @@ Name | Type |
|
|||
|
||||
___
|
||||
|
||||
### `Static` bigNumberify
|
||||
|
||||
▸ **bigNumberify**(`value`: any): *BigInt*
|
||||
|
||||
*Inherited from [Base](_src_base_.base.md).[bigNumberify](_src_base_.base.md#bignumberify)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`value` | any |
|
||||
|
||||
**Returns:** *BigInt*
|
||||
|
||||
___
|
||||
|
||||
### `Static` binarySearch
|
||||
|
||||
▸ **binarySearch**(`array`: Buffer[], `element`: Buffer, `compareFunction`: function): *number*
|
||||
|
@ -1262,6 +1312,23 @@ Name | Type | Description |
|
|||
|
||||
___
|
||||
|
||||
### `Static` hexZeroPad
|
||||
|
||||
▸ **hexZeroPad**(`hexStr`: string, `length`: number): *string*
|
||||
|
||||
*Inherited from [Base](_src_base_.base.md).[hexZeroPad](_src_base_.base.md#static-hexzeropad)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`hexStr` | string |
|
||||
`length` | number |
|
||||
|
||||
**Returns:** *string*
|
||||
|
||||
___
|
||||
|
||||
### `Static` isHexString
|
||||
|
||||
▸ **isHexString**(`v`: string): *boolean*
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
### Properties
|
||||
|
||||
* [complete](_src_merkletree_.options.md#optional-complete)
|
||||
* [concatenator](_src_merkletree_.options.md#optional-concatenator)
|
||||
* [duplicateOdd](_src_merkletree_.options.md#optional-duplicateodd)
|
||||
* [fillDefaultHash](_src_merkletree_.options.md#optional-filldefaulthash)
|
||||
* [hashLeaves](_src_merkletree_.options.md#optional-hashleaves)
|
||||
|
@ -29,6 +30,12 @@ If set to `true`, the resulting tree will be a complete tree. Recommended for us
|
|||
|
||||
___
|
||||
|
||||
### `Optional` concatenator
|
||||
|
||||
• **concatenator**? : *any*
|
||||
|
||||
___
|
||||
|
||||
### `Optional` duplicateOdd
|
||||
|
||||
• **duplicateOdd**? : *boolean*
|
||||
|
|
|
@ -76,4 +76,4 @@ ___
|
|||
|
||||
### TValue
|
||||
|
||||
Ƭ **TValue**: *Buffer | string | number | null | undefined*
|
||||
Ƭ **TValue**: *Buffer | BigInt | string | number | null | undefined*
|
||||
|
|
|
@ -32,7 +32,7 @@ export interface Options {
|
|||
/** If set to `true`, the resulting tree will be a complete tree. Recommended for use of multiProofs. */
|
||||
complete?: boolean;
|
||||
|
||||
concatFn?: any
|
||||
concatenator?: any
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ export interface Options {
|
|||
export class MerkleTree extends Base {
|
||||
private duplicateOdd: boolean = false
|
||||
private hashFn: THashFn
|
||||
private concatFn: any = Buffer.concat
|
||||
private concatenator: any = Buffer.concat
|
||||
private hashLeaves: boolean = false
|
||||
private isBitcoinTree: boolean = false
|
||||
private leaves: TLeaf[] = []
|
||||
|
@ -111,8 +111,8 @@ export class MerkleTree extends Base {
|
|||
|
||||
this.duplicateOdd = !!options.duplicateOdd
|
||||
|
||||
if (options.concatFn) {
|
||||
this.concatFn = options.concatFn
|
||||
if (options.concatenator) {
|
||||
this.concatenator = options.concatenator
|
||||
}
|
||||
|
||||
this.hashFn = this.bufferifyFn(hashFn)
|
||||
|
@ -1454,7 +1454,7 @@ export class MerkleTree extends Base {
|
|||
|
||||
combineHashes (hashes: Buffer[]) {
|
||||
hashes = hashes.filter(x => x.byteLength > 0)
|
||||
return this.concatFn(hashes)
|
||||
return this.concatenator(hashes)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1342,7 +1342,7 @@ test('poseidon hash', async t => {
|
|||
|
||||
const leaves = [1, 2, 3, 4].map(x => poseidonHash([x]))
|
||||
const tree = new MerkleTree(leaves, poseidonHash, {
|
||||
concatFn: (hashes) => hashes
|
||||
concatenator: (hashes) => hashes
|
||||
})
|
||||
t.equal(tree.getHexRoot(), '0xd24e045226875e22b37ce607ea2af7a9fbb137ee128caa0ce3663615350245')
|
||||
|
||||
|
|
Loading…
Reference in New Issue