pub struct Node<C: NodeConfig> { /* private fields */ }Expand description
The Node struct.
Implementations§
Source§impl<C: NodeConfig> Node<C>
impl<C: NodeConfig> Node<C>
Sourcepub fn new(
local_key: Keypair,
local_address: Multiaddr,
bootstrap_nodes: Vec<(PeerId, Multiaddr, f64)>,
) -> Result<Self, EigenError>
pub fn new( local_key: Keypair, local_address: Multiaddr, bootstrap_nodes: Vec<(PeerId, Multiaddr, f64)>, ) -> Result<Self, EigenError>
Create a new node, given the local keypair, local address, and bootstrap nodes.
Sourcepub fn get_peer_mut(&mut self) -> &mut Peer
pub fn get_peer_mut(&mut self) -> &mut Peer
Get the mutable peer struct.
Sourcepub fn get_swarm_mut(&mut self) -> &mut Swarm<RequestResponse<EigenTrustCodec>>
pub fn get_swarm_mut(&mut self) -> &mut Swarm<RequestResponse<EigenTrustCodec>>
Get the mutable swarm.
Sourcepub fn handle_req_res_events(
&mut self,
event: RequestResponseEvent<Request, Response>,
)
pub fn handle_req_res_events( &mut self, event: RequestResponseEvent<Request, Response>, )
Method for handling the request/response events.
Sourcepub fn handle_swarm_events(
&mut self,
event: SwarmEvent<RequestResponseEvent<Request, Response>, ConnectionHandlerUpgrErr<IoError>>,
)
pub fn handle_swarm_events( &mut self, event: SwarmEvent<RequestResponseEvent<Request, Response>, ConnectionHandlerUpgrErr<IoError>>, )
A method for handling the swarm events.
Sourcepub fn dial_neighbor(&mut self, addr: Multiaddr)
pub fn dial_neighbor(&mut self, addr: Multiaddr)
Dial the neighbor directly.
Sourcepub fn dial_bootstrap_nodes(&mut self)
pub fn dial_bootstrap_nodes(&mut self)
Dial pre-configured bootstrap nodes.
Sourcepub fn send_epoch_requests(&mut self, epoch: Epoch)
pub fn send_epoch_requests(&mut self, epoch: Epoch)
Send the request for an opinion to all neighbors, in the passed epoch.
Sourcepub async fn main_loop(
self,
interval_limit: Option<u32>,
) -> Result<(), EigenError>
pub async fn main_loop( self, interval_limit: Option<u32>, ) -> Result<(), EigenError>
Start the main loop of the program. This function has two main tasks:
- To start an interval timer for sending the request for opinions.
- To handle the swarm + request/response events.
The amount of intervals/epochs is determined by the
interval_limitparameter.
Auto Trait Implementations§
impl<C> !Freeze for Node<C>
impl<C> !RefUnwindSafe for Node<C>
impl<C> Send for Node<C>where
C: Send,
impl<C> !Sync for Node<C>
impl<C> Unpin for Node<C>where
C: Unpin,
impl<C> !UnwindSafe for Node<C>
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> 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>
Converts
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>
Converts
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