Compare commits
4 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | f44be464c2 | |
Derrick Hammer | e49de4e907 | |
Derrick Hammer | 45b3e884f9 | |
Derrick Hammer | a901ee76f4 |
|
@ -1,3 +1,10 @@
|
||||||
|
# [0.1.0-develop.41](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.40...v0.1.0-develop.41) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add loggerInfo and loggerErr callbacks to client options ([a901ee7](https://git.lumeweb.com/LumeWeb/libethsync/commit/a901ee76f4703d6e7f4793e96cfe173037f2103f))
|
||||||
|
|
||||||
# [0.1.0-develop.40](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.39...v0.1.0-develop.40) (2023-07-14)
|
# [0.1.0-develop.40](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.39...v0.1.0-develop.40) (2023-07-14)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libethclient",
|
"name": "@lumeweb/libethclient",
|
||||||
"version": "0.1.0-develop.40",
|
"version": "0.1.0-develop.41",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libethclient",
|
"name": "@lumeweb/libethclient",
|
||||||
"version": "0.1.0-develop.40",
|
"version": "0.1.0-develop.41",
|
||||||
"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.40",
|
"version": "0.1.0-develop.41",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -26,6 +26,8 @@ export interface BaseClientOptions {
|
||||||
store: IStore;
|
store: IStore;
|
||||||
optimisticUpdateCallback: OptimisticUpdateCallback;
|
optimisticUpdateCallback: OptimisticUpdateCallback;
|
||||||
syncDelay?: number;
|
syncDelay?: number;
|
||||||
|
loggerInfo: (...any) => void;
|
||||||
|
loggerErr: (...any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default abstract class BaseClient {
|
export default abstract class BaseClient {
|
||||||
|
@ -131,7 +133,9 @@ export default abstract class BaseClient {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!(validOrCommittee as boolean)) {
|
if (!(validOrCommittee as boolean)) {
|
||||||
console.log(`Found invalid update at period(${curPeriod})`);
|
this.options.loggerInfo(
|
||||||
|
`Found invalid update at period(${curPeriod})`,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
syncCommittee: startCommittee,
|
syncCommittee: startCommittee,
|
||||||
period: curPeriod,
|
period: curPeriod,
|
||||||
|
@ -239,7 +243,7 @@ export default abstract class BaseClient {
|
||||||
this._latestOptimisticUpdate =
|
this._latestOptimisticUpdate =
|
||||||
capella.ssz.LightClientOptimisticUpdate.serialize(update);
|
capella.ssz.LightClientOptimisticUpdate.serialize(update);
|
||||||
|
|
||||||
console.log(
|
this.options.loggerInfo(
|
||||||
`Optimistic update verified for slot ${update.attestedHeader.beacon.slot}`,
|
`Optimistic update verified for slot ${update.attestedHeader.beacon.slot}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default class Client extends BaseClient {
|
||||||
blockHash,
|
blockHash,
|
||||||
);
|
);
|
||||||
this.subscribe((ei) => {
|
this.subscribe((ei) => {
|
||||||
console.log(
|
this.options.loggerInfo(
|
||||||
`Received a new blockheader: ${ei.blockNumber} ${ei.blockHash}`,
|
`Received a new blockheader: ${ei.blockNumber} ${ei.blockHash}`,
|
||||||
);
|
);
|
||||||
provider.update(ei.blockNumber, ei.blockHash);
|
provider.update(ei.blockNumber, ei.blockHash);
|
||||||
|
|
|
@ -9,6 +9,9 @@ function createDefaultClient(
|
||||||
proverHandler: ProverRequestCallback,
|
proverHandler: ProverRequestCallback,
|
||||||
rpcHandler: Function,
|
rpcHandler: Function,
|
||||||
optimisticUpdateHandler: OptimisticUpdateCallback,
|
optimisticUpdateHandler: OptimisticUpdateCallback,
|
||||||
|
loggerInfo: (...any) => void,
|
||||||
|
loggerErr: (...any) => void,
|
||||||
|
syncDelay?: number,
|
||||||
): Client {
|
): Client {
|
||||||
return new Client({
|
return new Client({
|
||||||
prover: new Prover(proverHandler),
|
prover: new Prover(proverHandler),
|
||||||
|
@ -16,6 +19,9 @@ function createDefaultClient(
|
||||||
provider: VerifyingProvider,
|
provider: VerifyingProvider,
|
||||||
rpcHandler,
|
rpcHandler,
|
||||||
optimisticUpdateCallback: optimisticUpdateHandler,
|
optimisticUpdateCallback: optimisticUpdateHandler,
|
||||||
|
loggerInfo,
|
||||||
|
loggerErr,
|
||||||
|
syncDelay,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ function createDefaultClient(beaconUrl: string): Client {
|
||||||
|
|
||||||
return capella.ssz.LightClientOptimisticUpdate.fromJson(update);
|
return capella.ssz.LightClientOptimisticUpdate.fromJson(update);
|
||||||
},
|
},
|
||||||
|
loggerInfo: console.log,
|
||||||
|
loggerErr: console.error,
|
||||||
};
|
};
|
||||||
|
|
||||||
const client = new Client(options);
|
const client = new Client(options);
|
||||||
|
|
Loading…
Reference in New Issue