pub struct RotatingExplorerClient {
pub config: RotatingExplorerConfig,
pub endpoints: Vec<ExplorerEndpoint>,
/* private fields */
}Expand description
An explorer client that round-robins across multiple API endpoints.
On failure (when rotate_on_error is enabled), the client advances to the
next available healthy endpoint automatically.
Fields§
§config: RotatingExplorerConfigConfiguration
endpoints: Vec<ExplorerEndpoint>All tracked endpoints with health state
Implementations§
Source§impl RotatingExplorerClient
impl RotatingExplorerClient
Sourcepub fn new(config: RotatingExplorerConfig) -> Self
pub fn new(config: RotatingExplorerConfig) -> Self
Create a new RotatingExplorerClient from the given configuration.
Sourcepub fn current_endpoint(&self) -> Option<&str>
pub fn current_endpoint(&self) -> Option<&str>
Return the URL of the current healthy endpoint, if any.
Sourcepub fn mark_unhealthy(&self, index: usize)
pub fn mark_unhealthy(&self, index: usize)
Mark endpoint at index as unhealthy.
Sourcepub async fn get_transaction(
&self,
txid: &str,
) -> Result<ExplorerTransaction, BitcoinError>
pub async fn get_transaction( &self, txid: &str, ) -> Result<ExplorerTransaction, BitcoinError>
Retrieve a transaction from the current endpoint, rotating on failure.
Tries config.max_retries + 1 times before returning an error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RotatingExplorerClient
impl !RefUnwindSafe for RotatingExplorerClient
impl Send for RotatingExplorerClient
impl Sync for RotatingExplorerClient
impl Unpin for RotatingExplorerClient
impl UnsafeUnpin for RotatingExplorerClient
impl !UnwindSafe for RotatingExplorerClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more