Struct swarm_nl::setup::BootstrapConfig

source ·
pub struct BootstrapConfig { /* private fields */ }
Expand description

Configuration data required for node bootstrap.

Implementations§

source§

impl BootstrapConfig

source

pub fn from_file(file_path: &str) -> Self

Read from a bootstrap config file on disk.

§Panics

This function will panic if the file is not found at the specified path.

source

pub fn new() -> Self

Return a new BootstrapConfig struct populated by default (empty) values.

Must be called first if the config is to be explicitly built without reading .ini file from disk.

source

pub fn with_bootnodes( self, boot_nodes: HashMap<PeerIdString, MultiaddrString> ) -> Self

Configure available bootnodes.

source

pub fn with_blacklist(self, list: Vec<PeerId>) -> Self

Configure a list of peers to add to blacklist.

source

pub fn with_tcp(self, tcp_port: Port) -> Self

Configure the TCP/IP port.

Note: Port must range between MIN_PORT and MAX_PORT.

source

pub fn with_udp(self, udp_port: Port) -> Self

Configure the UDP port.

Note: Port must range between MIN_PORT and MAX_PORT

source

pub fn generate_keypair( self, key_type: KeyType, rsa_pk8_filepath: Option<&str> ) -> Self

Generate a Cryptographic Keypair for node identity creation and message signing.

An RSA keypair cannot be generated on-the-fly. It has to be generated from a .pk8 file. Hence the rsa_pk8_filepath parameter must always be set to None except in the case of RSA. Please note that calling this function overrides whatever might have been read from the .ini file

§Panics

This function will panic if:

  1. The RSA key type is specified and the rsa_pk8_filepath is set to None.
  2. If the file contains invalid data and an RSA keypair cannot be generated from it.
source

pub fn generate_keypair_from_protobuf( self, key_type_str: &str, bytes: &mut [u8] ) -> Self

Generate a Cryptographic Keypair from a protobuf format.

This will override any already set keypair.

§Panics

This function will panic if the u8 buffer is not parsable into the specified key type. This could be because one of two reasons:

  1. If the key type is valid, but the keypair data is not valid for that key type.
  2. If the key type is invalid.
source

pub fn keypair(&self) -> Keypair

Return a node’s cryptographic keypair.

source

pub fn ports(&self) -> (Port, Port)

Return the configured ports in a tuple i.e (TCP Port, UDP port).

source

pub fn bootnodes(&self) -> HashMap<PeerIdString, MultiaddrString>

Return the configured bootnodes for the network.

source

pub fn blacklist(&self) -> Blacklist

Return the PeerId’s of nodes that are to be blacklisted.

Trait Implementations§

source§

impl Debug for BootstrapConfig

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for BootstrapConfig

Default implementation for BootstrapConfig.

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more