Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
belopash committed Nov 1, 2024
1 parent 3c1b6f2 commit f413d5c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
24 changes: 14 additions & 10 deletions test/erc20-transfers/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const CONTRACT = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'.toLowerCase()


const processor = new EvmBatchProcessor()
.setPortal('https://portal.sqd.dev/datasets/ethereum-mainnet')
.setPortal({
url: 'https://portal.sqd.dev/datasets/ethereum-mainnet',
bufferThreshold: 100 * 1024 * 1024
})
// .setRpcEndpoint(process.env.ARB_NODE_WS)
.setFinalityConfirmation(500)
.setBlockRange({from: 0})
Expand All @@ -30,18 +33,19 @@ processor.run(new TypeormDatabase({supportHotBlocks: true}), async ctx => {
for (let log of block.logs) {
if (log.address == CONTRACT && erc20.events.Transfer.is(log)) {
// let {from, to, value} = erc20.events.Transfer.decode(log)
// transfers.push(new Transfer({
// id: log.id,
// blockNumber: block.header.height,
// timestamp: new Date(block.header.timestamp),
// tx: log.transactionHash,
// from,
// to,
// amount: value
// }))
transfers.push(new Transfer({
// id: log.id,
// blockNumber: block.header.height,
// timestamp: new Date(block.header.timestamp),
// tx: log.transactionHash,
// from,
// to,
// amount: value
}))
}
}
}

// ctx.log.info(`found ${transfers.length} transfers`)
// await ctx.store.insert(transfers)
})
6 changes: 4 additions & 2 deletions util/portal-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,18 @@ export class PortalClient {
let toBlock = query.toBlock ?? Infinity

while (fromBlock <= toBlock) {
let archiveQuery = {...query, fromBlock}

let res = await this.http
.request<NodeJS.ReadableStream>('POST', this.getRouterUrl(`stream`), {
json: {...query, fromBlock},
json: archiveQuery,
retryAttempts: 3,
httpTimeout: this.queryTimeout,
stream: true,
})
.catch(
withErrorContext({
archiveQuery: query,
archiveQuery,
})
)

Expand Down
2 changes: 1 addition & 1 deletion util/util-internal-ingest-tools/src/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function archiveIngest<B extends Block>(args: ArchiveIngestOptions): Asyn
assert(lastBlock >= beg)
beg = lastBlock + 1

if (beg > top) {
if (top < beg) {
top = await height.get()
}

Expand Down

0 comments on commit f413d5c

Please sign in to comment.