Compare commits

..

3 Commits

Author SHA1 Message Date
semantic-release-bot 919cb0b1df chore(release): 0.1.0-develop.60 [skip ci]
# [0.1.0-develop.60](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.59...v0.1.0-develop.60) (2023-09-16)

### Features

* add method to reset the client ([87d8be6](87d8be615e))
2023-09-16 15:52:27 +00:00
Derrick Hammer 3d4d24e90b
Merge remote-tracking branch 'origin/develop' into develop 2023-09-16 11:51:36 -04:00
Derrick Hammer 87d8be615e
feat: add method to reset the client 2023-09-16 11:51:30 -04:00
6 changed files with 22 additions and 3 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.60](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.59...v0.1.0-develop.60) (2023-09-16)
### Features
* add method to reset the client ([87d8be6](https://git.lumeweb.com/LumeWeb/libethsync/commit/87d8be615e42fef0ae122a29b83cd1974e4ee1a7))
# [0.1.0-develop.59](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.58...v0.1.0-develop.59) (2023-09-16) # [0.1.0-develop.59](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.58...v0.1.0-develop.59) (2023-09-16)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.59", "version": "0.1.0-develop.60",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.59", "version": "0.1.0-develop.60",
"dependencies": { "dependencies": {
"@chainsafe/as-sha256": "^0.3.1", "@chainsafe/as-sha256": "^0.3.1",
"@chainsafe/bls": "7.1.1", "@chainsafe/bls": "7.1.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.59", "version": "0.1.0-develop.60",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -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) { public async syncFromCheckpoint(checkpoint: LightClientUpdate) {
this._latestPeriod = computeSyncPeriodAtSlot( this._latestPeriod = computeSyncPeriodAtSlot(
checkpoint.attestedHeader.beacon.slot, checkpoint.attestedHeader.beacon.slot,

View File

@ -17,6 +17,7 @@ export interface IStore extends EventEmitter {
addUpdate(period: number, update: LightClientUpdate): void; addUpdate(period: number, update: LightClientUpdate): void;
getUpdate(period: number): Uint8Array; getUpdate(period: number): Uint8Array;
hasUpdate(period: number): boolean; hasUpdate(period: number): boolean;
clear(): void;
} }
export interface IVerifyingProvider { export interface IVerifyingProvider {

View File

@ -21,6 +21,10 @@ export default class Store extends EventEmitter implements IStore {
this.store.options.stdTTL = 0; this.store.options.stdTTL = 0;
} }
clear(): void {
this.store.flushAll();
}
addUpdate(period: number, update: LightClientUpdate) { addUpdate(period: number, update: LightClientUpdate) {
try { try {
const serialized = capella.ssz.LightClientUpdate.serialize(update); const serialized = capella.ssz.LightClientUpdate.serialize(update);