import { ConsensusResult, NetworkNode } from './types'; /** * Calculate consensus across network nodes * * Groups nodes by their current block and determines the consensus level: * - `none`: No healthy peers * - `error`: Only 0-1 healthy peers (insufficient for consensus) * - `partial`: Peers disagree on current block (<66% agreement) * - `mostly_agreed`: Majority agrees (>=66%) * - `fully_agreed`: All peers agree (100%) * * @param nodes - Array of network nodes to analyze * @returns ConsensusResult with level, block, and majority nodes * * @example * ```ts * const nodes = await Promise.all(endpoints.map(checkRpcHealth)) * const consensus = calculateConsensus(nodes) * * if (consensus.level === 'fully_agreed') { * console.log(`All nodes agree on block ${consensus.block}`) * } * ``` */ export declare function calculateConsensus(nodes: NetworkNode[]): ConsensusResult; /** * Select the best endpoint from a list of nodes * * Selection criteria: * 1. Must be in the consensus majority * 2. Lowest latency among majority nodes * * @param nodes - Array of network nodes * @returns Best node or null if no healthy nodes * * @example * ```ts * const nodes = await Promise.all(endpoints.map(checkRpcHealth)) * const best = selectBestEndpoint(nodes) * * if (best) { * console.log(`Best endpoint: ${best.endpoint} (${best.latency}ms)`) * } * ``` */ export declare function selectBestEndpoint(nodes: NetworkNode[]): NetworkNode | null; /** * Sort nodes by quality (healthy first, then by latency) * * @param nodes - Array of network nodes * @returns Sorted array (does not mutate original) */ export declare function sortNodesByQuality(nodes: NetworkNode[]): NetworkNode[];