pub struct Client<T> {
    inner: NodeClient<T>,
    legacy_node_id: Option<NodeId>,
}

Fields§

§inner: NodeClient<T>§legacy_node_id: Option<NodeId>

Implementations§

source§

impl Client<Channel>

source

pub async fn connect<D>(dst: D) -> Result<Self, Error>where D: TryInto<Endpoint>, D::Error: Into<StdError>,

source§

impl<T> Client<T>where T: GrpcService<BoxBody>, T::ResponseBody: Send + Sync + 'static, <T::ResponseBody as Body>::Error: Into<StdError> + Send,

source

pub fn new(service: T) -> Self

source

fn subscription_request<S>(&self, outbound: S) -> Request<S>

source

pub async fn handshake( &mut self, nonce: &[u8] ) -> Result<HandshakeResponse, HandshakeError>

Requests the identifier of the genesis block from the service node.

The implementation can also perform version information checks to ascertain that the client use compatible protocol versions.

This method should be called first after establishing the client connection.

source

pub async fn client_auth( &mut self, auth: AuthenticatedNodeId ) -> Result<(), Error>

source

pub async fn peers(&mut self, limit: u32) -> Result<Gossip, Error>

One-off request for a list of peers known to the remote node.

The peers are picked up accordingly to the Poldercast algorithm modules. This request is typically used during bootstrap from a trusted peer.

source

pub async fn tip(&mut self) -> Result<Header, Error>

Requests the header of the tip block in the node’s chain.

source

pub async fn get_blocks( &mut self, ids: BlockIds ) -> Result<InboundStream<Block, Block>, Error>

Requests the identified blocks in a streamed response.

source

pub async fn get_headers( &mut self, ids: BlockIds ) -> Result<InboundStream<Header, Header>, Error>

Requests the headers of the identified blocks in a streamed response.

source

pub async fn get_fragments( &mut self, ids: FragmentIds ) -> Result<InboundStream<Fragment, Fragment>, Error>

Requests the identified fragments in a streamed response.

source

pub async fn pull_blocks( &mut self, from: BlockIds, to: BlockId ) -> Result<InboundStream<Block, Block>, Error>

Stream blocks from the provided range.

source

pub async fn pull_blocks_to_tip( &mut self, from: BlockIds ) -> Result<InboundStream<Block, Block>, Error>

Stream blocks from the first of the given starting points that is found in the peer’s chain, to the chain’s tip.

source

pub async fn pull_headers( &mut self, from: BlockIds, to: BlockId ) -> Result<InboundStream<Header, Header>, Error>

Requests headers of blocks in the blockchain’s chronological order, in the range between the latest of the given starting points, and the given ending point. If none of the starting points are found in the chain on the service side, or if the ending point is not found, the future will fail with a NotFound error.

source

pub async fn push_headers<S>(&mut self, headers: S) -> Result<(), Error>where S: Stream<Item = Header> + Send + Sync + 'static,

The outbound counterpart of pull_headers, called in response to a BlockEvent::Missing solicitation. An empty stream can be used to indicate that the solicitation does not refer to blocks found in the local blockchain.

source

pub async fn upload_blocks<S>(&mut self, blocks: S) -> Result<(), Error>where S: Stream<Item = Block> + Send + Sync + 'static,

Uploads blocks to the service in response to BlockEvent::Solicit.

The blocks to send are retrieved asynchronously from the passed stream.

source

pub async fn block_subscription<S>( &mut self, outbound: S ) -> Result<BlockSubscription, Error>where S: Stream<Item = Header> + Send + Sync + 'static,

Establishes a bidirectional stream of notifications for blocks created or accepted by either of the peers.

The client can use the stream that the returned future resolves to as a long-lived subscription handle.

source

pub async fn fragment_subscription<S>( &mut self, outbound: S ) -> Result<FragmentSubscription, Error>where S: Stream<Item = Fragment> + Send + Sync + 'static,

Establishes a bidirectional stream for exchanging fragments created or accepted by either of the peers.

The client can use the stream that the returned future resolves to as a long-lived subscription handle.

source

pub async fn gossip_subscription<S>( &mut self, outbound: S ) -> Result<GossipSubscription, Error>where S: Stream<Item = Gossip> + Send + Sync + 'static,

Establishes a bidirectional stream for exchanging network gossip.

The client can use the stream that the returned future resolves to as a long-lived subscription handle.

Trait Implementations§

source§

impl<T: Clone> Clone for Client<T>

source§

fn clone(&self) -> Client<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Client<T>where T: RefUnwindSafe,

§

impl<T> Send for Client<T>where T: Send,

§

impl<T> Sync for Client<T>where T: Sync,

§

impl<T> Unpin for Client<T>where T: Unpin,

§

impl<T> UnwindSafe for Client<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more