refactor: simplify logic and fix not returning a value
This commit is contained in:
parent
3162dee81b
commit
07f8f81857
20
src/index.ts
20
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();
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue