Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Jan 23, 2025
1 parent c960ac9 commit 2553f53
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ async function main() {
const docHashes = [
utf8('{"example": "document"}'),
utf8('{"example": 2}'),
randomAsU8a(),
randomAsU8a(Math.floor(Math.random() * 64)),
utf8('{"example": 4}'),
].map((bytes) => Anchor.hash(bytes).bytes);
const proofs = await anchorBatched(anchor, docHashes);
assert((await checkBatched(anchor, docHashes[0], proofs[0])) !== null);
assert((await checkBatched(anchor, docHashes[0], proofs[1])) === null);

// single
const single = Anchor.hash(randomAsU8a()).bytes;
const single = Anchor.hash(randomAsU8a(Math.floor(Math.random() * 64))).bytes;
assert((await checkBatched(anchor, single, [])) === null);
await anchorBatched(anchor, [single]);
assert((await checkBatched(anchor, single, [])) !== null);
Expand Down Expand Up @@ -96,7 +96,7 @@ function benchSingleProofCreation(count) {
/* eslint-disable no-unused-vars */
const data = Array(count)
.fill(undefined)
.map((_, __) => randomAsU8a());
.map((_, __) => randomAsU8a(Math.floor(Math.random() * 64)));
const start = new Date().getTime();
const hashes = data.map((bytes) => Anchor.hash(bytes).bytes);
const pl = pack32(hashes);
Expand All @@ -118,7 +118,7 @@ function timeProofGeneration(count) {
/* eslint-disable no-unused-vars */
const data = Array(count)
.fill(undefined)
.map((_, __) => randomAsU8a());
.map((_, __) => randomAsU8a(Math.floor(Math.random() * 64)));
const start = new Date().getTime();
const hashes = data.map((bytes) => Anchor.hash(bytes).bytes);
const [root, proofs] = buildMerkleTreeAndProofs(hashes);
Expand Down

0 comments on commit 2553f53

Please sign in to comment.