Compare commits

..

3 Commits

Author SHA1 Message Date
semantic-release-bot 14f58027bd chore(release): 0.1.0-develop.19 [skip ci]
# [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-07-11)

### Features

* add getter for provider ([b85e177](b85e1779ee))
2023-07-11 08:16:35 +00:00
Derrick Hammer 5dd99f24e9
Merge remote-tracking branch 'origin/develop' into develop 2023-07-11 04:15:46 -04:00
Derrick Hammer b85e1779ee
feat: add getter for provider 2023-07-11 04:15:35 -04:00
4 changed files with 39 additions and 27 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-07-11)
### Features
* add getter for provider ([b85e177](https://git.lumeweb.com/LumeWeb/libethsync/commit/b85e1779ee7e4d8fccb6c7b8ee0e66f332823d19))
# [0.1.0-develop.18](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.17...v0.1.0-develop.18) (2023-07-11)

4
npm-shrinkwrap.json generated
View File

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

View File

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

View File

@ -21,13 +21,41 @@ interface Config extends BaseClientOptions {
}
export default class Client extends BaseClient {
private provider?: IVerifyingProvider;
protected declare options: Config;
constructor(options: Config) {
super(options);
}
private _provider?: IVerifyingProvider;
get provider(): IVerifyingProvider {
return this._provider as IVerifyingProvider;
}
async sync(): Promise<void> {
await super.sync();
if (!this._provider) {
const { blockHash, blockNumber } = await this.getNextValidExecutionInfo();
const factory = this.options.provider;
const provider = new factory(
this.options.rpcHandler,
blockNumber,
blockHash,
);
this.subscribe((ei) => {
console.log(
`Received a new blockheader: ${ei.blockNumber} ${ei.blockHash}`,
);
provider.update(ei.blockNumber, ei.blockHash);
});
this._provider = provider;
this.booted = true;
}
}
protected async getLatestExecution(): Promise<ExecutionInfo | null> {
const updateJSON = await this.options.prover.callback(
"consensus_optimistic_update",
@ -50,29 +78,6 @@ export default class Client extends BaseClient {
};
}
async sync(): Promise<void> {
await super.sync();
if (!this.provider) {
const { blockHash, blockNumber } = await this.getNextValidExecutionInfo();
const factory = this.options.provider;
const provider = new factory(
this.options.rpcHandler,
blockNumber,
blockHash,
);
this.subscribe((ei) => {
console.log(
`Received a new blockheader: ${ei.blockNumber} ${ei.blockHash}`,
);
provider.update(ei.blockNumber, ei.blockHash);
});
this.provider = provider;
this.booted = true;
}
}
protected syncFromGenesis(): Promise<Uint8Array[]> {
return Promise.resolve([]);
}