Struct sn_routing::Routing[][src]

pub struct Routing { /* fields omitted */ }
Expand description

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 sn_messaging::SrcLocation::Node or sn_messaging::SrcLocation::Section.

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 propose_offline(&self, name: XorName) -> Result<()>[src]

Starts a proposal that a node has gone offline. This can be done only by an Elder.

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 keypair_as_bytes(&self) -> [u8; 64][src]

Returns the ed25519 keypair of this node, as bytes.

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 section_chain(&self) -> SecuredLinkedList[src]

Returns the Section Proof Chain

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) -> SectionAuthorityProvider[src]

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

pub async fn other_sections(&self) -> Vec<SectionAuthorityProvider>[src]

Returns the info about other sections in the network known to us.

pub async fn section_key(&self, prefix: &Prefix) -> Option<PublicKey>[src]

Returns the last known public key of the section with prefix.

pub async fn matching_section(
    &self,
    name: &XorName
) -> Result<SectionAuthorityProvider>
[src]

Returns the info about the section matching the name.

pub async fn send_message(
    &self,
    itinerary: Itinerary,
    content: Bytes,
    additional_proof_chain_key: Option<PublicKey>
) -> 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.

additional_proof_chain_key is a key to be included in the proof chain attached to the message. This is useful when the message contains some data that is signed with a different key than the whole message is so that the recipient can verify such key.

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) -> SecuredLinkedList[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 Debug for Routing[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Drop for Routing[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

pub fn vzip(self) -> V