Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Sep 11, 2024
1 parent 74d8122 commit af933fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ export function* iterateDataColumnBytesFromWrapper(
}

const fork = chain.config.getForkName(blockSlot);
console.log("onDataColumnSidecarsByRange", {
slot: blockSlot,
columnsSize,
storedColumnsNum: allDataColumnSidecarsBytes.length / columnsSize,
});

for (const column of columns) {
// get the index at which the column is
const index = dataColumnsIndex[column] - 1;
const index = (dataColumnsIndex[column] ?? 0) - 1;
if (index < 0) {
throw new ResponseError(RespStatus.SERVER_ERROR, `dataColumnSidecar index=${column} not custodied`);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,21 @@ export async function* onDataColumnSidecarsByRoot(
CUSTODY_COLUMNS_IN_IN_WRAPPER_INDEX,
CUSTODY_COLUMNS_IN_IN_WRAPPER_INDEX + NUMBER_OF_COLUMNS
);
console.log({columnsSize, storedColumnsNum: dataColumnSidecarsBytes.length / columnsSize});
console.log("onDataColumnSidecarsByRoot", {
slot: block.slot,
columnsSize,
storedColumnsNum: dataColumnSidecarsBytes.length / columnsSize,
});

lastFetchedSideCars = {blockRoot: blockRootHex, bytes: dataColumnSidecarsBytes, columnsSize, dataColumnsIndex};
}

const dataIndex = lastFetchedSideCars.dataColumnsIndex[index] - 1;
const dataIndex = (lastFetchedSideCars.dataColumnsIndex[index] ?? 0) - 1;
if (dataIndex < 0) {
throw new ResponseError(RespStatus.SERVER_ERROR, `dataColumnSidecar index=${index} not custodied`);
}
const {columnsSize} = lastFetchedSideCars;

if (dataIndex === undefined || dataIndex === 0) {
throw Error(
`Missing dataColumnSidecar blockRoot=${blockRootHex} index=${index} calculated dataIndex=${dataIndex}`
);
}

// dataIndex is 1 based index
const dataColumnSidecarBytes = lastFetchedSideCars.bytes.slice(
dataIndex * columnsSize,
(dataIndex + 1) * columnsSize
Expand Down

0 comments on commit af933fb

Please sign in to comment.