From da730d909b18f1694e55f106fb82b3046397cc3a Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 29 Nov 2023 15:51:20 +0000 Subject: [PATCH] using Promise.all --- yarn-project/aztec-node/src/aztec-node/server.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index eb43c1962ff..817b1a6b206 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -400,14 +400,19 @@ export class AztecNodeService implements AztecNode { if (!index) { return undefined; } - const leafData = await committedDb.getLeafData(MerkleTreeId.NULLIFIER_TREE, Number(index)); - if (!leafData) { - return undefined; - } - const siblingPath = await committedDb.getSiblingPath( + + const leafDataPromise = committedDb.getLeafData(MerkleTreeId.NULLIFIER_TREE, Number(index)); + const siblingPathPromise = committedDb.getSiblingPath( MerkleTreeId.NULLIFIER_TREE, BigInt(index), ); + + const [leafData, siblingPath] = await Promise.all([leafDataPromise, siblingPathPromise]); + + if (!leafData) { + return undefined; + } + return new NullifierMembershipWitness(BigInt(index), leafData, siblingPath); }