pub struct ServerConnection {
pub client: ArkServiceClient<InterceptedService<Channel, ProtocolVersionInterceptor>>,
pub mailbox_client: MailboxServiceClient<InterceptedService<Channel, ProtocolVersionInterceptor>>,
/* private fields */
}Expand description
A managed connection to the Ark server.
This type encapsulates:
pver: The negotiated protocol version for the current session.info: The server’s ArkInfo configuration snapshot retrieved at connection time.client: A ready-to-use gRPC client bound to the same channel used for the handshake.
Fields§
§client: ArkServiceClient<InterceptedService<Channel, ProtocolVersionInterceptor>>The gRPC client to call Ark RPCs.
mailbox_client: MailboxServiceClient<InterceptedService<Channel, ProtocolVersionInterceptor>>The mailbox gRPC client to call mailbox RPCs.
Implementations§
Source§impl ServerConnection
impl ServerConnection
Sourcepub async fn connect(
address: &str,
network: Network,
) -> Result<ServerConnection, ConnectError>
pub async fn connect( address: &str, network: Network, ) -> Result<ServerConnection, ConnectError>
Establish a connection to an Ark server and perform protocol negotiation.
Steps performed:
- Build and connect a gRPC channel to
address(with TLS for https). - Perform the handshake RPC, sending the Bark client version.
- Validate the server’s supported protocol range against MIN_PROTOCOL_VERSION..=MAX_PROTOCOL_VERSION and select a version.
- Create a client with a protocol-version interceptor to tag future calls.
- Fetch ArkInfo and verify it matches the provided Bitcoin Network.
Returns a ServerConnection with:
- the negotiated protocol version,
- the server’s configuration snapshot,
- and a gRPC client bound to the established channel.
Errors if the server cannot be reached, handshake fails, protocol versions
are incompatible, or the server’s network does not match network.
Sourcepub async fn check_connection(&self) -> Result<(), ConnectError>
pub async fn check_connection(&self) -> Result<(), ConnectError>
Checks the connection to the Ark server by performing an handshake request.
Sourcepub async fn ark_info(&self) -> Result<ArkInfo, ConnectError>
pub async fn ark_info(&self) -> Result<ArkInfo, ConnectError>
Returns a ArkInfoHandle
If the Ark info is outdated, a new request will be sent to the Ark server to refresh it asynchronously.
The handle also contains a receiver that will be signalled when the Ark info is successfully refreshed.
Trait Implementations§
Source§impl Clone for ServerConnection
impl Clone for ServerConnection
Source§fn clone(&self) -> ServerConnection
fn clone(&self) -> ServerConnection
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for ServerConnection
impl !RefUnwindSafe for ServerConnection
impl Send for ServerConnection
impl Sync for ServerConnection
impl Unpin for ServerConnection
impl UnsafeUnpin for ServerConnection
impl !UnwindSafe for ServerConnection
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request