import { BaseConnectionManager } from './base.manager';
export class MempoolConnectionManager extends BaseConnectionManager {
    constructor() {
        super(...arguments);
        this.activeProviderName = '';
        this._isAvailable = false;
    }
    get isAvailable() {
        return this._isAvailable;
    }
    async initialize() {
        if (this.providers.size === 0) {
            this.logger.log?.('No EVM mempool providers configured — mempool disabled', { module: this.moduleName });
            return;
        }
        const { connected } = await this.ensureConnectedAll();
        for (const provider of connected) {
            const healthy = await provider.healthcheck().catch(() => false);
            if (!healthy)
                continue;
            this.activeProviderName = provider.uniqName;
            this._isAvailable = true;
            return;
        }
        this._isAvailable = false;
        this.logger.warn?.('No EVM mempool providers could connect — mempool disabled', { module: this.moduleName });
    }
    getActiveProvider() {
        if (!this._isAvailable)
            return null;
        return this.providers.get(this.activeProviderName) ?? null;
    }
}
