pub struct Network { /* private fields */ }Expand description
Network abstraction for the Autonomi client.
Wraps a P2PNode providing high-level operations for
peer discovery and message routing.
Implementations§
Source§impl Network
impl Network
Sourcepub async fn new(
bootstrap_peers: &[SocketAddr],
allow_loopback: bool,
ipv6: bool,
) -> Result<Self>
pub async fn new( bootstrap_peers: &[SocketAddr], allow_loopback: bool, ipv6: bool, ) -> Result<Self>
Create a new network connection with the given bootstrap peers.
allow_loopback controls the saorsa-transport local flag on the
underlying CoreNodeConfig. Set it to true only for devnet / local
testing. Public Autonomi network peers reject the QUIC handshake
variant produced when local = true, so production callers must pass
false (this is what ant-cli does by default — see
ant-cli/src/main.rs::create_client_node_raw, which builds a similar
CoreNodeConfig directly, with ipv6 toggled by the --ipv4-only
flag).
ipv6 controls whether the node binds a dual-stack IPv6 socket
(true) or an IPv4-only socket (false). The default for library
callers should be true to match the CLI default; set it to false
only when running on hosts without a working IPv6 stack, to avoid
advertising unreachable v6 addresses to the DHT.
§Errors
Returns an error if the P2P node cannot be created or bootstrapping fails.
Sourcepub async fn find_closest_peers(
&self,
target: &[u8; 32],
count: usize,
) -> Result<Vec<(PeerId, Vec<MultiAddr>)>>
pub async fn find_closest_peers( &self, target: &[u8; 32], count: usize, ) -> Result<Vec<(PeerId, Vec<MultiAddr>)>>
Find the closest peers to a target address.
Returns each peer paired with its known network addresses, enabling
callers to pass addresses to send_and_await_chunk_response for
faster connection establishment.
§Errors
Returns an error if the DHT lookup fails.
Sourcepub async fn connected_peers(&self) -> Vec<PeerId>
pub async fn connected_peers(&self) -> Vec<PeerId>
Get all currently connected peers.
Auto Trait Implementations§
impl Freeze for Network
impl !RefUnwindSafe for Network
impl Send for Network
impl Sync for Network
impl Unpin for Network
impl UnsafeUnpin for Network
impl !UnwindSafe for Network
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> 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