@lodestar/api
Version:
A Typescript REST client for the Ethereum Consensus API
121 lines • 4.99 kB
TypeScript
import { ContainerType, ValueOf } from "@chainsafe/ssz";
import { ChainForkConfig } from "@lodestar/config";
import { EmptyArgs, EmptyMeta, EmptyRequest, EmptyResponseData } from "../../utils/codecs.js";
import { Endpoint, RouteDefinitions } from "../../utils/index.js";
export declare const NetworkIdentityType: ContainerType<{
/** Cryptographic hash of a peer’s public key. [Read more](https://docs.libp2p.io/concepts/peer-id/) */
peerId: import("@lodestar/types").StringType<string>;
/** Ethereum node record. [Read more](https://eips.ethereum.org/EIPS/eip-778) */
enr: import("@lodestar/types").StringType<string>;
p2pAddresses: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<string>, unknown, unknown>;
discoveryAddresses: import("@chainsafe/ssz").ArrayType<import("@chainsafe/ssz").Type<string>, unknown, unknown>;
/** Based on Ethereum Consensus [Metadata object](https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#metadata) */
metadata: ContainerType<{
seqNumber: import("@chainsafe/ssz").UintBigintType;
attnets: import("@chainsafe/ssz").BitVectorType;
syncnets: import("@chainsafe/ssz").BitVectorType;
}>;
}>;
export declare const PeerCountType: ContainerType<{
disconnected: import("@chainsafe/ssz").UintNumberType;
connecting: import("@chainsafe/ssz").UintNumberType;
connected: import("@chainsafe/ssz").UintNumberType;
disconnecting: import("@chainsafe/ssz").UintNumberType;
}>;
export declare const SyncingStatusType: ContainerType<{
/** Head slot node is trying to reach */
headSlot: import("@chainsafe/ssz").UintNumberType;
/** How many slots node needs to process to reach head. 0 if synced. */
syncDistance: import("@chainsafe/ssz").UintNumberType;
/** Set to true if the node is syncing, false if the node is synced. */
isSyncing: import("@chainsafe/ssz").BooleanType;
/** Set to true if the node is optimistically tracking head. */
isOptimistic: import("@chainsafe/ssz").BooleanType;
/** Set to true if the connected el client is offline */
elOffline: import("@chainsafe/ssz").BooleanType;
}>;
export type NetworkIdentity = ValueOf<typeof NetworkIdentityType>;
export type PeerState = "disconnected" | "connecting" | "connected" | "disconnecting";
export type PeerDirection = "inbound" | "outbound";
export type NodePeer = {
peerId: string;
enr: string;
lastSeenP2pAddress: string;
state: PeerState;
direction: PeerDirection | null;
};
export type PeersMeta = {
count: number;
};
export type PeerCount = ValueOf<typeof PeerCountType>;
export type FilterGetPeers = {
state?: PeerState[];
direction?: PeerDirection[];
};
export type SyncingStatus = ValueOf<typeof SyncingStatusType>;
export declare enum NodeHealth {
READY = 200,
SYNCING = 206,
NOT_INITIALIZED_OR_ISSUES = 503
}
/**
* Read information about the beacon node.
*/
export type Endpoints = {
/**
* Get node network identity
* Retrieves data about the node's network presence
*/
getNetworkIdentity: Endpoint<"GET", EmptyArgs, EmptyRequest, NetworkIdentity, EmptyMeta>;
/**
* Get node network peers
* Retrieves data about the node's network peers. By default this returns all peers. Multiple query params are combined using AND conditions
*/
getPeers: Endpoint<"GET", FilterGetPeers, {
query: {
state?: PeerState[];
direction?: PeerDirection[];
};
}, NodePeer[], PeersMeta>;
/**
* Get peer
* Retrieves data about the given peer
*/
getPeer: Endpoint<"GET", {
peerId: string;
}, {
params: {
peer_id: string;
};
}, NodePeer, EmptyMeta>;
/**
* Get peer count
* Retrieves number of known peers.
*/
getPeerCount: Endpoint<"GET", EmptyArgs, EmptyRequest, PeerCount, EmptyMeta>;
/**
* Get version string of the running beacon node.
* Requests that the beacon node identify information about its implementation in a format similar to a [HTTP User-Agent](https://tools.ietf.org/html/rfc7231#section-5.5.3) field.
*/
getNodeVersion: Endpoint<"GET", EmptyArgs, EmptyRequest, {
version: string;
}, EmptyMeta>;
/**
* Get node syncing status
* Requests the beacon node to describe if it's currently syncing or not, and if it is, what block it is up to.
*/
getSyncingStatus: Endpoint<"GET", EmptyArgs, EmptyRequest, SyncingStatus, EmptyMeta>;
/**
* Get health check
* Returns node health status in http status codes. Useful for load balancers.
*/
getHealth: Endpoint<"GET", {
syncingStatus?: number;
}, {
query: {
syncing_status?: number;
};
}, EmptyResponseData, EmptyMeta>;
};
export declare function getDefinitions(_config: ChainForkConfig): RouteDefinitions<Endpoints>;
//# sourceMappingURL=node.d.ts.map