Compare commits
3 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 14f58027bd | |
Derrick Hammer | 5dd99f24e9 | |
Derrick Hammer | b85e1779ee |
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lumeweb/libethsync",
|
||||
"version": "0.1.0-develop.18",
|
||||
"version": "0.1.0-develop.19",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -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([]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue