pub struct PeerConfig {
pub npub: String,
pub alias: Option<String>,
pub addresses: Vec<PeerAddress>,
pub connect_policy: ConnectPolicy,
pub auto_reconnect: bool,
}Expand description
Configuration for a known peer.
Peers are identified by their Nostr public key (npub) and can have multiple transport addresses for reaching them.
Fields§
§npub: StringThe peer’s Nostr public key in npub (bech32) or hex format.
alias: Option<String>Human-readable alias for the peer (optional).
addresses: Vec<PeerAddress>Transport addresses for reaching this peer.
At least one address is required unless Nostr discovery is enabled, in which case the address list may be empty and endpoints are resolved from the peer’s Nostr advert at dial time.
connect_policy: ConnectPolicyConnection policy for this peer.
auto_reconnect: boolWhether to automatically reconnect after link-dead removal. When true (default), the node will retry connecting with exponential backoff after MMP removes this peer due to liveness timeout.
Implementations§
Source§impl PeerConfig
impl PeerConfig
Sourcepub fn new(
npub: impl Into<String>,
transport: impl Into<String>,
addr: impl Into<String>,
) -> Self
pub fn new( npub: impl Into<String>, transport: impl Into<String>, addr: impl Into<String>, ) -> Self
Create a new peer config with a single address.
Sourcepub fn with_alias(self, alias: impl Into<String>) -> Self
pub fn with_alias(self, alias: impl Into<String>) -> Self
Set an alias for the peer.
Sourcepub fn with_address(self, addr: PeerAddress) -> Self
pub fn with_address(self, addr: PeerAddress) -> Self
Add an additional address for the peer.
Sourcepub fn addresses_by_priority(&self) -> Vec<&PeerAddress>
pub fn addresses_by_priority(&self) -> Vec<&PeerAddress>
Get addresses sorted by priority (lowest first).
Sourcepub fn is_auto_connect(&self) -> bool
pub fn is_auto_connect(&self) -> bool
Check if this peer should auto-connect on startup.
Trait Implementations§
Source§impl Clone for PeerConfig
impl Clone for PeerConfig
Source§fn clone(&self) -> PeerConfig
fn clone(&self) -> PeerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PeerConfig
impl Debug for PeerConfig
Source§impl Default for PeerConfig
impl Default for PeerConfig
Source§impl<'de> Deserialize<'de> for PeerConfig
impl<'de> Deserialize<'de> for PeerConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PeerConfig
impl RefUnwindSafe for PeerConfig
impl Send for PeerConfig
impl Sync for PeerConfig
impl Unpin for PeerConfig
impl UnsafeUnpin for PeerConfig
impl UnwindSafe for PeerConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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