Struct chain_network::grpc::client::Client
source · pub struct Client<T> {
inner: NodeClient<T>,
legacy_node_id: Option<NodeId>,
}
Fields§
§inner: NodeClient<T>
§legacy_node_id: Option<NodeId>
Implementations§
source§impl<T> Client<T>where
T: GrpcService<BoxBody>,
T::ResponseBody: Send + Sync + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + Send,
impl<T> Client<T>where T: GrpcService<BoxBody>, T::ResponseBody: Send + Sync + 'static, <T::ResponseBody as Body>::Error: Into<StdError> + Send,
pub fn new(service: T) -> Self
fn subscription_request<S>(&self, outbound: S) -> Request<S>
sourcepub async fn handshake(
&mut self,
nonce: &[u8]
) -> Result<HandshakeResponse, HandshakeError>
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.
pub async fn client_auth( &mut self, auth: AuthenticatedNodeId ) -> Result<(), Error>
sourcepub async fn peers(&mut self, limit: u32) -> Result<Gossip, Error>
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.
sourcepub async fn tip(&mut self) -> Result<Header, Error>
pub async fn tip(&mut self) -> Result<Header, Error>
Requests the header of the tip block in the node’s chain.
sourcepub async fn get_blocks(
&mut self,
ids: BlockIds
) -> Result<InboundStream<Block, Block>, Error>
pub async fn get_blocks( &mut self, ids: BlockIds ) -> Result<InboundStream<Block, Block>, Error>
Requests the identified blocks in a streamed response.
sourcepub async fn get_headers(
&mut self,
ids: BlockIds
) -> Result<InboundStream<Header, Header>, Error>
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.
sourcepub async fn get_fragments(
&mut self,
ids: FragmentIds
) -> Result<InboundStream<Fragment, Fragment>, Error>
pub async fn get_fragments( &mut self, ids: FragmentIds ) -> Result<InboundStream<Fragment, Fragment>, Error>
Requests the identified fragments in a streamed response.
sourcepub async fn pull_blocks(
&mut self,
from: BlockIds,
to: BlockId
) -> Result<InboundStream<Block, Block>, Error>
pub async fn pull_blocks( &mut self, from: BlockIds, to: BlockId ) -> Result<InboundStream<Block, Block>, Error>
Stream blocks from the provided range.
sourcepub async fn pull_blocks_to_tip(
&mut self,
from: BlockIds
) -> Result<InboundStream<Block, Block>, Error>
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.
sourcepub async fn pull_headers(
&mut self,
from: BlockIds,
to: BlockId
) -> Result<InboundStream<Header, Header>, Error>
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.
sourcepub async fn push_headers<S>(&mut self, headers: S) -> Result<(), Error>where
S: Stream<Item = Header> + Send + Sync + 'static,
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.
sourcepub async fn upload_blocks<S>(&mut self, blocks: S) -> Result<(), Error>where
S: Stream<Item = Block> + Send + Sync + 'static,
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.
sourcepub async fn block_subscription<S>(
&mut self,
outbound: S
) -> Result<BlockSubscription, Error>where
S: Stream<Item = Header> + Send + Sync + 'static,
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.
sourcepub async fn fragment_subscription<S>(
&mut self,
outbound: S
) -> Result<FragmentSubscription, Error>where
S: Stream<Item = Fragment> + Send + Sync + 'static,
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.
sourcepub async fn gossip_subscription<S>(
&mut self,
outbound: S
) -> Result<GossipSubscription, Error>where
S: Stream<Item = Gossip> + Send + Sync + 'static,
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§
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> 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
T
in a tonic::Request