Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket: use batch request in getLogs #107

Merged
merged 4 commits into from
Nov 15, 2023
Merged

websocket: use batch request in getLogs #107

merged 4 commits into from
Nov 15, 2023

Conversation

taokayan
Copy link
Contributor

Resolves #69

  • eth_getBlockByNumber always bundled with eth_getLogs
  • the block number in the batch request is always at least 1 block behind the latest block, to avoid some race condition where getLogs may return empty result for the latest block.

if( last == undefined ) {
last = await this.web3.eth.getBlock("latest", true);
this.append_new_block(last);
if( last == undefined || last == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this redundant?

const logs = results.data[1].result;

//console.log("RPC batch result:" + JSON.stringify(block));
return {block, logs};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put logs as a property of blocks?

blocks.logs = logs
return block

@@ -49,8 +49,8 @@ class SubscriptionServer extends EventEmitter {
await this.handle_block_forked({block});
});

this.block_monitor.on('block_appended', async ({block}) => {
await this.handle_block_appended({block});
this.block_monitor.on('block_appended', async ({block, logs}) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use logs as a property of block we should revert some modifications here

@taokayan taokayan requested a review from elmato November 15, 2023 09:49
@elmato elmato merged commit f75ce6a into main Nov 15, 2023
6 checks passed
@elmato elmato deleted the kayan_ws_getlogs branch November 15, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebSocket proxy: Query logs in a batch request
2 participants