openzeppelin_relayer::utils::rpc_selector

Function create_weights_distribution

Source
pub fn create_weights_distribution(
    configs: &[RpcConfig],
) -> Option<Arc<WeightedIndex<u8>>>
Expand description

Creates a weighted distribution for selecting RPC endpoints based on their weights.

§Arguments

  • configs - A slice of RPC configurations with weights

§Returns

  • Option<Arc<WeightedIndex<u8>>> - A weighted distribution if configs have different weights, None otherwise