@accumulators/merkle-mountain-range
Advanced tools
Comparing version 3.0.3 to 3.0.7
@@ -14,4 +14,6 @@ import { AppendResult, PeaksFormattingOptions, Proof, ProofOptions, PeaksOptions } from "./types"; | ||
bagThePeaks(elementsCount?: number): Promise<string>; | ||
private static countOnes; | ||
static mapLeafIndexToElementIndex(leafIndex: number): number; | ||
retrievePeaksHashes(peaksIdxs: number[], formattingOpts?: PeaksFormattingOptions): Promise<string[]>; | ||
clear(): Promise<void>; | ||
} |
@@ -175,2 +175,14 @@ "use strict"; | ||
} | ||
static countOnes(value) { | ||
let n = value; | ||
let onesCount = 0; | ||
while (n > 0) { | ||
n = n & (n - 1); | ||
onesCount++; | ||
} | ||
return onesCount; | ||
} | ||
static mapLeafIndexToElementIndex(leafIndex) { | ||
return 2 * leafIndex - 1 - this.countOnes(leafIndex - 1); | ||
} | ||
async retrievePeaksHashes(peaksIdxs, formattingOpts) { | ||
@@ -177,0 +189,0 @@ const hashes = await this.hashes.getMany(peaksIdxs); |
{ | ||
"name": "@accumulators/merkle-mountain-range", | ||
"version": "3.0.3", | ||
"version": "3.0.7", | ||
"description": "A TypeScript implementation of Merkle Mountain Ranges", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "32874d15a33696896c4b0189f4699642da399849" | ||
"gitHead": "f06f68ccfa058d5301a3e1bb8781619a299cd168" | ||
} |
Sorry, the diff of this file is not supported yet
42585
549