pub struct Resolver { /* private fields */ }Expand description
Connection resolver, the type is cheaply clonable and thus a single instance should be initialized and cloned between threads if necessary
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub async fn new(config: Configuration) -> Result<Self, Error>
pub async fn new(config: Configuration) -> Result<Self, Error>
Initialize the resolver with the provided configuration
Sourcepub async fn new_custom(
config: Configuration,
use_on_chain_routes: bool,
custom_routes: Option<HashMap<Pubkey, String>>,
) -> Result<Self, Error>
pub async fn new_custom( config: Configuration, use_on_chain_routes: bool, custom_routes: Option<HashMap<Pubkey, String>>, ) -> Result<Self, Error>
Initialize the resolver:
- fetch routes from chain (if use_on_chain_routes is true)
- add custom routes to routing table, if any
- subscribe to on-chain route updates (if use_on_chain_routes is true)
- creating websocket connection to base chain for delegation status tracking of accounts
Sourcepub async fn track_account(
&self,
pubkey: Pubkey,
) -> Result<DelegationStatus, Error>
pub async fn track_account( &self, pubkey: Pubkey, ) -> Result<DelegationStatus, Error>
Start tracking account’s delegation status, this is achieved by fetching the delegation record for the account (if it exists) and subscribing to updates of its state. The existence of the delegation record is a proof that account has been delegated, and it contains critical information like the identity of validator, to which the account was delegated
Sourcepub async fn resolve(&self, pubkey: &Pubkey) -> Result<Arc<RpcClient>, Error>
pub async fn resolve(&self, pubkey: &Pubkey) -> Result<Arc<RpcClient>, Error>
Resolve connection for given account, if account has been delegated (as observed by resolver), then the returned client is configured to connect to corresponding ER instance, otherwise the client will connect to base layer chain
Sourcepub async fn resolve_for_transaction(
&self,
tx: &Transaction,
) -> Result<Arc<RpcClient>, Error>
pub async fn resolve_for_transaction( &self, tx: &Transaction, ) -> Result<Arc<RpcClient>, Error>
Resolve connection for given transaction, if any of the accounts have been delegated (as observed by resolver), then the resolver will check that all the writable accounts in transaction have been delegated to the same ER, if validation is successful, the returned client is configured to connect to this common ER. If none of the accounts are delegated then the returned client is configured to connect to base layer chain. If conflict in delegation is found, i.e. writable accounts are delegated to different ERs, then error is returned as connection resolution is impossible for such a case.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resolver
impl !RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl UnsafeUnpin for Resolver
impl !UnwindSafe for Resolver
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more