@lodestar/beacon-node
Version:
A Typescript implementation of the beacon chain
36 lines • 1.57 kB
TypeScript
import { PeerSyncMeta } from "../../../network/peers/peersData.js";
import { CustodyConfig } from "../../../util/dataColumns.js";
import { RangeSyncType } from "../../utils/remoteSyncType.js";
import { Batch } from "../batch.js";
import { ChainTarget } from "./chainTarget.js";
export type PeerSyncInfo = PeerSyncMeta & {
target: ChainTarget;
};
/**
* Balance and organize peers to perform requests with a SyncChain
* Shuffles peers only once on instantiation
*/
export declare class ChainPeersBalancer {
private peers;
private activeRequestsByPeer;
private readonly custodyConfig;
private readonly syncType;
private readonly maxConcurrentRequests;
/**
* No need to specify `maxConcurrentRequests` for production code
* It is used for testing purposes to limit the number of concurrent requests
*/
constructor(peers: PeerSyncInfo[], batches: Batch[], custodyConfig: CustodyConfig, syncType: RangeSyncType, maxConcurrentRequests?: number);
/**
* Return the most suitable peer to retry
* Sort peers by (1) less active requests (2) most columns we need.
* Peers that failed this batch or already succeeded for the same request are excluded inside `filterPeers`.
*/
bestPeerToRetryBatch(batch: Batch): PeerSyncMeta | undefined;
/**
* Return peers with 0 or no active requests that has a higher target slot than this batch and has columns we need.
*/
idlePeerForBatch(batch: Batch): PeerSyncInfo | undefined;
private filterPeers;
}
//# sourceMappingURL=peerBalancer.d.ts.map