Skip to content

Conversation

@LeoPatOZ
Copy link
Collaborator

@LeoPatOZ LeoPatOZ commented Oct 27, 2025

Resolves #6 #142

Comment on lines 382 to 385
/// let scanner = EventScannerBuilder::historic()
/// .fallback_ws(fallback_url)
/// .connect_ws::<Ethereum>(ws_url)
/// .await?;
Copy link
Collaborator

@0xNeshi 0xNeshi Oct 30, 2025

Choose a reason for hiding this comment

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

I'm wondering whether it makes sense to construct the RobustProvider separately, and then pass that to the event scanner builder 🤔 The provider has a lot of configs, and it's possible the configs may increase in number.

Current API mixes provider and scanner configs:

let scanner = EventScannerBuilder::historic()
    .from_block(500)
    .fallback_ws(ws_url)
    .fallback_ws(fallback_url)
    .max_retries(5)
    .timeout(100)
    .build()?; 

Alternative separates them:

let provider = RobustProvider::<Ethereum>::new()
    .ws(ws_url) // or: `.add_websocket`, `.add_ipc`, that might be even better
    .ws(fallback_url)
    .max_retries(5)
    .timeout(100)
    .build()
    .await?;

let scanner = EventScannerBuilder::historic()
    .from_block(500)
    .provider(provider)
    .build()?; // maybe even this becomes sync

This would even allow the scanner to support both alloy's Provider and our own RobustProvider (depending on what the scanner user needs):

// maybe the dev needs something simple

let provider = RootProvider::<Ethereum>::new(...);

let scanner = EventScannerBuilder::historic()
    .from_block(500)
    .provider(provider)
    .build()?; 

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually was debating this but ended up choosing this way - which i see now is actually not great.

I think we should go with passing in the RobustProvider directly instead of muddling this api with both the scanner and provider methods.

@LeoPatOZ LeoPatOZ marked this pull request as draft October 30, 2025 13:00
@LeoPatOZ LeoPatOZ marked this pull request as ready for review November 3, 2025 12:58
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.

Add Multiple Endpoints as Providers

3 participants