Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramon committed May 2, 2024
1 parent a60fcee commit 5fd469c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions adapters/secta/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const readBlocksFromCSV = async (filePath: string): Promise<BlockData[]> => {

await new Promise<void>((resolve, reject) => {
fs.createReadStream(filePath)
.pipe(csv({ separator: "\t" })) // Specify the separator as '\t' for TSV files
.pipe(csv({ separator: "," })) // Specify the separator as '\t' for TSV files
.on("data", (row) => {
//console.log(row);
const blockNumber = parseInt(row.number, 10);
const blockTimestamp = parseInt(row.block_timestamp, 10);
const blockTimestamp = parseInt(row.timestamp, 10);
//console.log(`Maybe Data ${blockNumber} ${blockTimestamp}`);
if (!isNaN(blockNumber) && blockTimestamp) {
//console.log(`Valid Data`);
Expand Down Expand Up @@ -152,22 +152,17 @@ export const getUserTVLByBlock = async (blocks: BlockData) => {
return csvRows;
};

readBlocksFromCSV(path.resolve(__dirname, "../block_numbers_secta.tsv"))
readBlocksFromCSV(path.resolve(__dirname, "../hourly_blocks.csv"))
.then(async (blocks) => {
console.log(blocks);
const allCsvRows: any[] = []; // Array to accumulate CSV rows for all blocks
const batchSize = 10; // Size of batch to trigger writing to the file
let i = 0;

for (const block of blocks) {
try {
const result = await getUserTVLByBlock(block);

// Accumulate CSV rows for all blocks
allCsvRows.push(...result);

i++;
console.log(`Processed block ${i}`);
} catch (error) {
console.error(`An error occurred for block ${block}:`, error);
}
Expand Down

0 comments on commit 5fd469c

Please sign in to comment.