feat: add method to reset the client
This commit is contained in:
parent
5a5c320a25
commit
87d8be615e
|
@ -46,6 +46,13 @@ export default class Client extends BaseClient {
|
|||
}
|
||||
}
|
||||
|
||||
public reset() {
|
||||
this._latestPeriod = 0;
|
||||
this.latestCommittee = undefined;
|
||||
this.booted = false;
|
||||
this.store.clear();
|
||||
}
|
||||
|
||||
public async syncFromCheckpoint(checkpoint: LightClientUpdate) {
|
||||
this._latestPeriod = computeSyncPeriodAtSlot(
|
||||
checkpoint.attestedHeader.beacon.slot,
|
||||
|
|
|
@ -17,6 +17,7 @@ export interface IStore extends EventEmitter {
|
|||
addUpdate(period: number, update: LightClientUpdate): void;
|
||||
getUpdate(period: number): Uint8Array;
|
||||
hasUpdate(period: number): boolean;
|
||||
clear(): void;
|
||||
}
|
||||
|
||||
export interface IVerifyingProvider {
|
||||
|
|
|
@ -21,6 +21,10 @@ export default class Store extends EventEmitter implements IStore {
|
|||
this.store.options.stdTTL = 0;
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.store.flushAll();
|
||||
}
|
||||
|
||||
addUpdate(period: number, update: LightClientUpdate) {
|
||||
try {
|
||||
const serialized = capella.ssz.LightClientUpdate.serialize(update);
|
||||
|
|
Loading…
Reference in New Issue