Compare commits
5 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | d1a133d859 | |
Derrick Hammer | 6eaf874e44 | |
Derrick Hammer | e567d5017d | |
Derrick Hammer | f68688ab61 | |
Derrick Hammer | 661e146636 |
|
@ -1,3 +1,10 @@
|
||||||
|
# [0.1.0-develop.32](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.31...v0.1.0-develop.32) (2023-07-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add getCurrentBlock and getLastBlock methods ([661e146](https://git.lumeweb.com/LumeWeb/libethsync/commit/661e146636a9f685e8cbae04c52b1d0a1ede3bff))
|
||||||
|
|
||||||
# [0.1.0-develop.31](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.30...v0.1.0-develop.31) (2023-07-13)
|
# [0.1.0-develop.31](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.30...v0.1.0-develop.31) (2023-07-13)
|
||||||
|
|
||||||
# [0.1.0-develop.30](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.29...v0.1.0-develop.30) (2023-07-13)
|
# [0.1.0-develop.30](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.29...v0.1.0-develop.30) (2023-07-13)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libethclient",
|
"name": "@lumeweb/libethclient",
|
||||||
"version": "0.1.0-develop.31",
|
"version": "0.1.0-develop.32",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libethclient",
|
"name": "@lumeweb/libethclient",
|
||||||
"version": "0.1.0-develop.31",
|
"version": "0.1.0-develop.32",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/as-sha256": "^0.3.1",
|
"@chainsafe/as-sha256": "^0.3.1",
|
||||||
"@chainsafe/bls": "7.1.1",
|
"@chainsafe/bls": "7.1.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libethsync",
|
"name": "@lumeweb/libethsync",
|
||||||
"version": "0.1.0-develop.31",
|
"version": "0.1.0-develop.32",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -58,7 +58,10 @@ export default abstract class BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isSynced() {
|
public get isSynced() {
|
||||||
return this._latestPeriod === this.getCurrentPeriod();
|
return (
|
||||||
|
this._latestPeriod === this.getCurrentPeriod() &&
|
||||||
|
this.getLastBlock() === this.getCurrentBlock()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get store(): IStore {
|
public get store(): IStore {
|
||||||
|
@ -69,6 +72,7 @@ export default abstract class BaseClient {
|
||||||
await init("herumi");
|
await init("herumi");
|
||||||
|
|
||||||
await this._sync();
|
await this._sync();
|
||||||
|
await this.getLatestExecution(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentPeriod(): number {
|
public getCurrentPeriod(): number {
|
||||||
|
@ -77,6 +81,19 @@ export default abstract class BaseClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getCurrentBlock(): number {
|
||||||
|
return getCurrentSlot(this.config.chainConfig, this.genesisTime);
|
||||||
|
}
|
||||||
|
public getLastBlock(): number | null {
|
||||||
|
if (this._latestOptimisticUpdate) {
|
||||||
|
return capella.ssz.LightClientOptimisticUpdate.deserialize(
|
||||||
|
this._latestOptimisticUpdate,
|
||||||
|
).attestedHeader.beacon.slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public async getNextValidExecutionInfo(
|
public async getNextValidExecutionInfo(
|
||||||
retry: number = 10,
|
retry: number = 10,
|
||||||
): Promise<ExecutionInfo> {
|
): Promise<ExecutionInfo> {
|
||||||
|
@ -171,8 +188,10 @@ export default abstract class BaseClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLatestExecution(): Promise<ExecutionInfo | null> {
|
async getLatestExecution(sync = true): Promise<ExecutionInfo | null> {
|
||||||
await this._sync();
|
if (sync) {
|
||||||
|
await this._sync();
|
||||||
|
}
|
||||||
|
|
||||||
const getExecInfo = (u: OptimisticUpdate) => {
|
const getExecInfo = (u: OptimisticUpdate) => {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue