refactor: simplify logic and fix not returning a value

This commit is contained in:
Derrick Hammer 2023-07-11 18:24:32 -04:00
parent 3162dee81b
commit 07f8f81857
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 16 deletions

View File

@ -38,11 +38,9 @@ const plugin: Plugin = {
throw new Error('count required and must be a number"'); throw new Error('count required and must be a number"');
} }
let hashes: Uint8Array = new Uint8Array();
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
try { try {
hashes = client.store.getCommitteeHashes( return await client.store.getCommitteeHashes(
request.start, request.start,
request.count, request.count,
); );
@ -54,7 +52,7 @@ const plugin: Plugin = {
} }
} }
return hashes; return new Uint8Array();
}, },
}); });
@ -76,11 +74,9 @@ const plugin: Plugin = {
await client.sync(); await client.sync();
} }
let committee;
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
try { try {
committee = client.store.getCommittee( return await client.store.getCommittee(
request.period === "latest" request.period === "latest"
? client.latestPeriod ? client.latestPeriod
: request.period, : request.period,
@ -93,15 +89,7 @@ const plugin: Plugin = {
} }
} }
try { return new Uint8Array();
committee = client.store.getCommittee(
request.period === "latest" ? client.latestPeriod : request.period,
);
} catch {
await client.sync();
}
return committee;
}, },
}); });