- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2
 
Add Multiple providers #140
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
base: main
Are you sure you want to change the base?
Conversation
doc doc
remove import remove wrapped
Co-authored-by: Nenad <nenad.misic@openzeppelin.com>
        
          
                src/event_scanner/scanner/mod.rs
              
                Outdated
          
        
      | /// let scanner = EventScannerBuilder::historic() | ||
| /// .fallback_ws(fallback_url) | ||
| /// .connect_ws::<Ethereum>(ws_url) | ||
| /// .await?; | 
There was a problem hiding this comment.
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 syncThis 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()?; There was a problem hiding this comment.
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.
Resolves #6 #142