import type { ChainResult, MultiChainResult } from "./types"; export const mergeChainResults = ( chainResults: ChainResult[], computeTimeSec: number, ): MultiChainResult => { const sorted = [...chainResults].sort((a, b) => a.chainId - b.chainId); const paramNames = sorted[0].paramNames; // concatenate draws across chains, per parameter const draws = paramNames.map((_, p) => sorted.flatMap((c) => c.draws[p])); return { paramNames, draws, numChains: sorted.length, computeTimeSec, consoleText: sorted .map((c) => `--- chain ${c.chainId} ---\n${c.consoleText}`) .join("\n"), }; };