Node

Struct Node 

Source
pub struct Node<C: NodeConfig> { /* private fields */ }
Expand description

The Node struct.

Implementations§

Source§

impl<C: NodeConfig> Node<C>

Source

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.

Source

pub fn get_peer(&self) -> &Peer

Get the peer struct.

Source

pub fn get_peer_mut(&mut self) -> &mut Peer

Get the mutable peer struct.

Source

pub fn get_swarm_mut(&mut self) -> &mut Swarm<RequestResponse<EigenTrustCodec>>

Get the mutable swarm.

Source

pub fn handle_req_res_events( &mut self, event: RequestResponseEvent<Request, Response>, )

Method for handling the request/response events.

Source

pub fn handle_swarm_events( &mut self, event: SwarmEvent<RequestResponseEvent<Request, Response>, ConnectionHandlerUpgrErr<IoError>>, )

A method for handling the swarm events.

Source

pub fn dial_neighbor(&mut self, addr: Multiaddr)

Dial the neighbor directly.

Source

pub fn dial_bootstrap_nodes(&mut self)

Dial pre-configured bootstrap nodes.

Source

pub fn send_epoch_requests(&mut self, epoch: Epoch)

Send the request for an opinion to all neighbors, in the passed epoch.

Source

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_limit parameter.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

Source§

impl<T, U> Into<U> for T
where 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,