/** * Swarm connection manager: delegates to {@link BareOsSwarmPeerPolicyEngine} for * peer health, scoring, backoff/ban windows, and replication scheduling hints. */ import { BareOsSwarmPeerPolicyEngine } from './bare-os-swarm-peer-policy.js' export class BareOsSwarmConnectionManager { /** * @param {import('hyperswarm').default | null} swarm * @param {{ env?: Record | null }} [opts] */ constructor(swarm, opts = {}) { this._engine = new BareOsSwarmPeerPolicyEngine(swarm, opts) } get swarm() { return this._engine.swarm } /** * @param {string} peerKey * @param {boolean} ok * @param {{ latencyMs?: number }} [probeMeta] */ noteProbe(peerKey, ok, probeMeta) { this._engine.noteProbe(peerKey, ok, probeMeta) } /** * @param {string} peerKey */ shouldAttemptPeer(peerKey) { return this._engine.shouldAttemptPeer(peerKey) } /** * @param {string} peerKey */ consumeReconnectBudget(peerKey) { this._engine.consumeReconnectBudget(peerKey) } /** * @param {string} peerKey * @param {number} [amount] */ replenishReconnectBudget(peerKey, amount) { this._engine.replenishReconnectBudget(peerKey, amount) } /** * @param {string} peerKey */ score(peerKey) { return this._engine.score(peerKey) } snapshot() { return this._engine.snapshot() } /** * @param {string[]} peerKeys */ rankPeers(peerKeys) { return this._engine.rankPeers(peerKeys) } }