import { ChainName } from '../types'; /** * Type of network node */ export type NodeType = 'rpc' | 'squid' | 'datapod'; /** * Status of a network node */ export type NodeStatus = 'pending' | 'healthy' | 'unhealthy' | 'timeout'; /** * Consensus level across network nodes */ export type ConsensusLevel = 'none' | 'pending' | 'error' | 'partial' | 'mostly_agreed' | 'fully_agreed'; /** * Information about a network node */ export interface NetworkNode { /** Endpoint URL (wss:// for RPC, https:// for squid) */ endpoint: string; /** Type of node */ type: NodeType; /** Current health status */ status: NodeStatus; /** Response latency in milliseconds */ latency?: number; /** Current block height */ currentBlock?: number; /** Node software version */ version?: string; /** Peer ID from duniter_peerings */ peerId?: string; /** Last health check timestamp */ lastChecked?: Date; /** Error if unhealthy */ error?: Error; } /** * Result of consensus calculation */ export interface ConsensusResult { /** Consensus level */ level: ConsensusLevel; /** Agreed block number (null if no consensus) */ block: number | null; /** Nodes in the majority group */ majority: NetworkNode[]; /** Total healthy nodes */ total: number; } /** * Options for network scanning */ export interface ScanOptions { /** Timeout per node check in ms (default: 5000) */ timeout?: number; /** Max concurrent checks (default: 5) */ concurrency?: number; /** Include unhealthy nodes in results (default: false) */ includeUnhealthy?: boolean; /** AbortSignal to cancel scan */ signal?: AbortSignal; } /** * Result of a network scan */ export interface ScanResult { /** Chain that was scanned */ chain: ChainName; /** Timestamp of scan */ scannedAt: Date; /** All discovered nodes */ nodes: NetworkNode[]; /** Best RPC node (lowest latency in majority) */ bestRpc?: NetworkNode; /** Best Squid node (lowest latency in majority) */ bestSquid?: NetworkNode; /** Consensus block number */ consensusBlock?: number; /** Current consensus level */ consensusLevel: ConsensusLevel; } /** * Peering information from duniter_peerings RPC */ export interface Peering { peer_id: string; endpoints: { address: string; protocol: string; }[]; }