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"');
|
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;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue