style: reformat

This commit is contained in:
Derrick Hammer 2023-07-13 03:14:06 -04:00
parent b3e5607132
commit 4836ddb32e
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 50 additions and 49 deletions

View File

@ -86,6 +86,56 @@ export default abstract class BaseClient {
return this.getNextValidExecutionInfo(retry - 1); return this.getNextValidExecutionInfo(retry - 1);
} }
async syncProver(
startPeriod: number,
currentPeriod: number,
startCommittee: Uint8Array[],
): Promise<{ syncCommittee: Uint8Array[]; period: number }> {
try {
const updates = await this.options.prover.getSyncUpdate(
startPeriod,
currentPeriod - startPeriod,
);
for (let i = 0; i < updates.length; i++) {
const curPeriod = startPeriod + i;
const update = updates[i];
const updatePeriod = computeSyncPeriodAtSlot(
update.attestedHeader.beacon.slot,
);
const validOrCommittee = await this.syncUpdateVerifyGetCommittee(
startCommittee,
curPeriod,
update,
);
if (!(validOrCommittee as boolean)) {
console.log(`Found invalid update at period(${curPeriod})`);
return {
syncCommittee: startCommittee,
period: curPeriod,
};
}
await this.options.store.addUpdate(curPeriod, update);
startCommittee = validOrCommittee as Uint8Array[];
}
} catch (e) {
console.error(`failed to fetch sync update for period(${startPeriod})`);
return {
syncCommittee: startCommittee,
period: startPeriod,
};
}
return {
syncCommittee: startCommittee,
period: currentPeriod,
};
}
protected async _sync() { protected async _sync() {
await this.syncMutex.acquire(); await this.syncMutex.acquire();
@ -142,55 +192,6 @@ export default abstract class BaseClient {
blockNumber: update.attestedHeader.execution.blockNumber, blockNumber: update.attestedHeader.execution.blockNumber,
}; };
} }
async syncProver(
startPeriod: number,
currentPeriod: number,
startCommittee: Uint8Array[],
): Promise<{ syncCommittee: Uint8Array[]; period: number }> {
try {
const updates = await this.options.prover.getSyncUpdate(
startPeriod,
currentPeriod - startPeriod,
);
for (let i = 0; i < updates.length; i++) {
const curPeriod = startPeriod + i;
const update = updates[i];
const updatePeriod = computeSyncPeriodAtSlot(
update.attestedHeader.beacon.slot,
);
const validOrCommittee = await this.syncUpdateVerifyGetCommittee(
startCommittee,
curPeriod,
update,
);
if (!(validOrCommittee as boolean)) {
console.log(`Found invalid update at period(${curPeriod})`);
return {
syncCommittee: startCommittee,
period: curPeriod,
};
}
await this.options.store.addUpdate(curPeriod, update);
startCommittee = validOrCommittee as Uint8Array[];
}
} catch (e) {
console.error(`failed to fetch sync update for period(${startPeriod})`);
return {
syncCommittee: startCommittee,
period: startPeriod,
};
}
return {
syncCommittee: startCommittee,
period: currentPeriod,
};
}
protected async syncUpdateVerifyGetCommittee( protected async syncUpdateVerifyGetCommittee(
prevCommittee: Uint8Array[], prevCommittee: Uint8Array[],