UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

31 lines 1.6 kB
import { PeerId } from "@libp2p/interface"; import { GoodByeReasonCode } from "../../../constants/network.js"; import { PeerIdStr } from "../../../util/peerId.js"; import { NetworkCoreMetrics } from "../../core/metrics.js"; import { IPeerRpcScoreStore, PeerAction, PeerRpcScoreOpts, PeerScoreStats, ScoreState } from "./interface.js"; /** * A peer's score (perceived potential usefulness). * This simplistic version consists of a global score per peer which decays to 0 over time. * The decay rate applies equally to positive and negative scores. * Peer cool-down period will be checked before dialing and will only be dialed if score is not waiting to decay */ export declare class PeerRpcScoreStore implements IPeerRpcScoreStore { private readonly scores; private readonly metrics; constructor(opts?: PeerRpcScoreOpts, metrics?: NetworkCoreMetrics | null); getScore(peer: PeerId): number; getGossipScore(peer: PeerId): number; getScoreState(peer: PeerId): ScoreState; isCoolingDown(peerIdStr: PeerIdStr): boolean; dumpPeerScoreStats(): PeerScoreStats; applyAction(peer: PeerId, action: PeerAction, actionName: string): void; /** * Apply a reconnection cool-down period to prevent automatic reconnection. Sets peer * banning period and updates gossip score to -1 so next update removes the negative * score */ applyReconnectionCoolDown(peer: PeerIdStr, reason: GoodByeReasonCode): number; update(): void; updateGossipsubScore(peerId: PeerIdStr, newScore: number, ignore: boolean): void; } //# sourceMappingURL=store.d.ts.map