Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Feb 28, 2024
1 parent 980c512 commit 7385cf1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/utils/algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function decompressOrders(compressed: CompressedOrder[]): Record<ProsperitySymbo
return orders;
}

function decompressSandboxLogRow(compressed: CompressedAlgorithmDataRow, sandboxLogs: string): AlgorithmDataRow {
function decompressDataRow(compressed: CompressedAlgorithmDataRow, sandboxLogs: string): AlgorithmDataRow {
return {
state: decompressState(compressed[0]),
orders: decompressOrders(compressed[1]),
Expand All @@ -183,7 +183,7 @@ function decompressSandboxLogRow(compressed: CompressedAlgorithmDataRow, sandbox
};
}

function getSandboxLogs(logLines: string[]): AlgorithmDataRow[] {
function getAlgorithmData(logLines: string[]): AlgorithmDataRow[] {
const headerIndex = logLines.indexOf('Sandbox logs:');
if (headerIndex === -1) {
return [];
Expand Down Expand Up @@ -214,8 +214,8 @@ function getSandboxLogs(logLines: string[]): AlgorithmDataRow[] {
const end = line.lastIndexOf(']') + 1;

try {
const compressedLogRow = JSON.parse(JSON.parse(line.substring(start, end) + '"'));
rows.push(decompressSandboxLogRow(compressedLogRow, nextSandboxLogs));
const compressedDataRow = JSON.parse(JSON.parse(line.substring(start, end) + '"'));
rows.push(decompressDataRow(compressedDataRow, nextSandboxLogs));
} catch (err) {
console.log(line);
console.error(err);
Expand All @@ -230,16 +230,16 @@ export function parseAlgorithmLogs(logs: string, summary?: AlgorithmSummary): Al
const logLines = logs.trim().split('\n');

const activityLogs = getActivityLogs(logLines);
const sandboxLogs = getSandboxLogs(logLines);
const data = getAlgorithmData(logLines);

if (activityLogs.length === 0 || sandboxLogs.length === 0) {
if (activityLogs.length === 0 || data.length === 0) {
throw new Error('Logs are in invalid format, please see the prerequisites section above.');
}

return {
summary,
activityLogs,
data: sandboxLogs,
data,
};
}

Expand Down

0 comments on commit 7385cf1

Please sign in to comment.