const CANONICAL_LEDGER_CONFIG = Object.freeze({
  id: String(process.env.AISFOR_CHAIN_CANONICAL_LEDGER || 'legacy-mock').trim().toLowerCase(),
  expectedId: 'besu-qbft',
  role: 'canonical-candidate-ledger',
  legacyRole: 'legacy-read-only-archive',
  blockTimeTargetSec: Math.max(1, Number(process.env.PLAIS_QBFT_BLOCK_TIME_SEC || 2)),
  maxBlockAgeSec: Math.max(10, Number(process.env.PLAIS_QBFT_MAX_BLOCK_AGE_SEC || 30)),
  requiredIndependentHosts: Math.max(1, Number(process.env.PLAIS_QBFT_REQUIRED_INDEPENDENT_HOSTS || 4))
});

function isCanonicalBesuQbft() {
  return CANONICAL_LEDGER_CONFIG.id === CANONICAL_LEDGER_CONFIG.expectedId;
}

module.exports = {
  CANONICAL_LEDGER_CONFIG,
  isCanonicalBesuQbft
};
