Skip to content

RobustProvider: Client Should be Able to Pass Different Types of Provider-related Types Into .fallback #185

@0xNeshi

Description

@0xNeshi

Currently we define the providers as a Vec<P> where P: IntoProvider.

The issue is once we pass in the 'main' provider, we now bind generic P to the primary provider's (sub)type.

So this is not possible:

        let ws_string: &str = "ws_example";
        let robust: RobustProvider<Ethereum> = RobustProviderBuilder::new(ws_provider)
            .fallback(ws_string)
            .call_timeout(Duration::from_secs(5))
            .build()
            .await?;

You need (where both primary and fallback are same type):

        let ws_string: &str = "ws_example";
        let robust: RobustProvider<Ethereum> = RobustProviderBuilder::new(ws_string)
            .fallback(ws_string)
            .call_timeout(Duration::from_secs(5))
            .build()
            .await?;

This is not the desired API. The client should have the benefit of 'mixing' provider types.

The solution to this might entail the use of LazyProvider wrapper types, so the internal vector type would be "fixed" to Vec<LazyProvider<N>> where N: Network, but internally the LazyProvider would be able to store different provider connection types.

Related #165

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementImprovement to existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions