Struct sn_routing::Routing[][src]

pub struct Routing { /* fields omitted */ }

Interface for sending and receiving messages to and from other nodes, in the role of a full routing node.

A node is a part of the network that can route messages and be a member of a section or group location. Its methods can be used to send requests and responses as either an individual Node or as a part of a section or group location. Their src argument indicates that role, and can be any SrcLocation.

Implementations

impl Routing[src]

pub async fn new(config: Config) -> Result<(Self, EventStream)>[src]

Creates new node using the given config and bootstraps it to the network.

NOTE: It's not guaranteed this function ever returns. This can happen due to messages being lost in transit during bootstrapping, or other reasons. It's the responsibility of the caller to handle this case, for example by using a timeout.

pub async fn set_joins_allowed(&self, joins_allowed: bool) -> Result<()>[src]

Sets the JoinsAllowed flag.

pub async fn age(&self) -> u8[src]

Returns the current age of this node.

pub async fn public_key(&self) -> PublicKey[src]

Returns the ed25519 public key of this node.

pub async fn sign_as_node(&self, data: &[u8]) -> Signature[src]

Signs data with the ed25519 key of this node.

pub async fn sign_as_elder(
    &self,
    data: &[u8],
    public_key: &PublicKey
) -> Result<SignatureShare>
[src]

Signs data with the BLS secret key share of this node, if it has any. Returns Error::MissingSecretKeyShare otherwise.

pub async fn verify(&self, data: &[u8], signature: &Signature) -> bool[src]

Verifies signature on data with the ed25519 public key of this node.

pub async fn name(&self) -> XorName[src]

The name of this node.

pub fn our_connection_info(&self) -> SocketAddr[src]

Returns connection info of this node.

pub async fn our_prefix(&self) -> Prefix[src]

Prefix of our section

pub async fn matches_our_prefix(&self, name: &XorName) -> bool[src]

Finds out if the given XorName matches our prefix.

pub async fn is_elder(&self) -> bool[src]

Returns whether the node is Elder.

pub async fn our_elders(&self) -> Vec<Peer>[src]

Returns the information of all the current section elders.

pub async fn our_elders_sorted_by_distance_to(
    &self,
    name: &XorName
) -> Vec<Peer>
[src]

Returns the elders of our section sorted by their distance to name (closest first).

pub async fn our_adults(&self) -> Vec<Peer>[src]

Returns the information of all the current section adults.

pub async fn our_adults_sorted_by_distance_to(
    &self,
    name: &XorName
) -> Vec<Peer>
[src]

Returns the adults of our section sorted by their distance to name (closest first). If we are not elder or if there are no adults in the section, returns empty vec.

pub async fn our_section(&self) -> EldersInfo[src]

Returns the info about our section or None if we are not joined yet.

pub async fn neighbour_sections(&self) -> Vec<EldersInfo>[src]

Returns the info about our neighbour sections.

pub async fn match_section(
    &self,
    name: &XorName
) -> (Option<PublicKey>, Option<EldersInfo>)
[src]

Returns the info about the section matches the name.

pub async fn send_message(
    &self,
    src: SrcLocation,
    dst: DstLocation,
    content: Bytes
) -> Result<()>
[src]

Send a message. Messages sent here, either section to section or node to node are signed and validated upon receipt by routing itself.

pub async fn send_message_to_client(
    &self,
    recipient: SocketAddr,
    message: MsgEnvelope
) -> Result<()>
[src]

Send a message to a client peer. Messages sent to a client are not signed or validated as part of the routing library.

pub async fn public_key_set(&self) -> Result<PublicKeySet>[src]

Returns the current BLS public key set if this node has one, or Error::InvalidState otherwise.

pub async fn our_history(&self) -> SectionProofChain[src]

Returns our section proof chain.

pub async fn our_index(&self) -> Result<usize>[src]

Returns our index in the current BLS group if this node is a member of one, or Error::MissingSecretKeyShare otherwise.

Trait Implementations

impl Drop for Routing[src]

Auto Trait Implementations

impl !RefUnwindSafe for Routing

impl Send for Routing

impl Sync for Routing

impl Unpin for Routing

impl !UnwindSafe for Routing

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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