fix: add a sync delay option so that the bls verification does not hog cpu

This commit is contained in:
Derrick Hammer 2023-07-14 09:21:52 -04:00
parent 8aa7c11f09
commit 824dcd9633
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 7 additions and 0 deletions

View File

@ -25,6 +25,7 @@ export interface BaseClientOptions {
prover: IProver;
store: IStore;
optimisticUpdateCallback: OptimisticUpdateCallback;
syncDelay?: number;
}
export default abstract class BaseClient {
@ -140,6 +141,12 @@ export default abstract class BaseClient {
await this.options.store.addUpdate(curPeriod, update);
startCommittee = validOrCommittee as Uint8Array[];
if (this.options.syncDelay) {
await new Promise((resolve) =>
setTimeout(resolve, this.options.syncDelay),
);
}
}
} catch (e) {
console.error(`failed to fetch sync update for period(${startPeriod})`);