From 07f8f8185744b59e452659f1d131e31571ead431 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 11 Jul 2023 18:24:32 -0400 Subject: [PATCH] refactor: simplify logic and fix not returning a value --- src/index.ts | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6e7f527..cfdec87 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,11 +38,9 @@ const plugin: Plugin = { throw new Error('count required and must be a number"'); } - let hashes: Uint8Array = new Uint8Array(); - for (let i = 0; i < 4; i++) { try { - hashes = client.store.getCommitteeHashes( + return await client.store.getCommitteeHashes( request.start, request.count, ); @@ -54,7 +52,7 @@ const plugin: Plugin = { } } - return hashes; + return new Uint8Array(); }, }); @@ -76,11 +74,9 @@ const plugin: Plugin = { await client.sync(); } - let committee; - for (let i = 0; i < 4; i++) { try { - committee = client.store.getCommittee( + return await client.store.getCommittee( request.period === "latest" ? client.latestPeriod : request.period, @@ -93,15 +89,7 @@ const plugin: Plugin = { } } - try { - committee = client.store.getCommittee( - request.period === "latest" ? client.latestPeriod : request.period, - ); - } catch { - await client.sync(); - } - - return committee; + return new Uint8Array(); }, });