pub struct SolanaClientRateLimit {
pub endpoint_amounts: HashMap<RpcRequest, u64>,
pub ignore_endpoints: HashSet<RpcRequest>,
pub last_datetime: i64,
pub interval: i64,
pub consumed_amount: u64,
pub maximum_amount: u64,
pub default_amount_per_endpoint: u64,
}
Expand description
Limit for rates like requests per second or compute units per interval.
Fields
endpoint_amounts: HashMap<RpcRequest, u64>
Map that contains the amount given to each endpoint.
ignore_endpoints: HashSet<RpcRequest>
Set of endpoints ignored by this limit.
last_datetime: i64
The last date this limit was updated.
interval: i64
Interval between rate resets expressed in milliseconds.
consumed_amount: u64
The number of requests or compute units already consumed in the current interval.
maximum_amount: u64
The maximum number of requests or compute units allowed per interval.
default_amount_per_endpoint: u64
The default amount for each endpoint if not specified in endpoint_amounts
.
Implementations
sourceimpl SolanaClientRateLimit
impl SolanaClientRateLimit
pub fn new(
interval: u64,
maximum_amount: u64,
default_amount_per_endpoint: u64
) -> Self
sourcepub fn add_endpoint_amount(self, endpoint: RpcRequest, amount: u64) -> Self
pub fn add_endpoint_amount(self, endpoint: RpcRequest, amount: u64) -> Self
Adds a RpcRequest
to the map of endpoints to their amounts.
sourcepub fn ignore_endpoint(self, endpoint: RpcRequest) -> Self
pub fn ignore_endpoint(self, endpoint: RpcRequest) -> Self
Adds a RpcRequest
to the list of ignored endpoints.
sourcepub fn ignores_all_endpoints(self) -> Self
pub fn ignores_all_endpoints(self) -> Self
Adds all RpcRequest
to the list of ignored endpoints.
sourcepub fn check_endpoint(&mut self, endpoint: RpcRequest) -> bool
pub fn check_endpoint(&mut self, endpoint: RpcRequest) -> bool
Checks whether the endpoint can be executed according to the current limits.
sourcepub fn check_endpoints(&mut self, endpoints: &[RpcRequest]) -> bool
pub fn check_endpoints(&mut self, endpoints: &[RpcRequest]) -> bool
Checks whether the endpoints can be executed according to the current limits.
sourcepub fn apply_endpoint(&mut self, endpoint: RpcRequest)
pub fn apply_endpoint(&mut self, endpoint: RpcRequest)
Applies the changes of executing the endpoint.
sourcepub fn apply_endpoints(&mut self, endpoints: &[RpcRequest])
pub fn apply_endpoints(&mut self, endpoints: &[RpcRequest])
Applies the changes of executing the endpoints.