[][src]Struct sv::peer::Peer

pub struct Peer {
    pub id: ProcessUniqueId,
    pub ip: IpAddr,
    pub port: u16,
    pub network: Network,
    // some fields omitted
}

Node on the network to send and receive messages

It will setup a connection, respond to pings, and store basic properties about the connection, but any real logic to process messages will be handled outside. Network messages received will be published to an observable on the peer's receiver thread. Messages may be sent via send() from any thread. Once shutdown, the Peer may no longer be used.

Fields

id: ProcessUniqueId

Unique id for this connection

ip: IpAddr

IP address

port: u16

Port

network: Network

Network

Implementations

impl Peer[src]

pub fn connect(
    ip: IpAddr,
    port: u16,
    network: Network,
    version: Version,
    filter: Arc<dyn PeerFilter>
) -> Arc<Peer>
[src]

Creates a new peer and begins connecting

pub fn send(&self, message: &Message) -> Result<()>[src]

Sends a message to the peer

pub fn disconnect(&self)[src]

Disconects and disables the peer

pub fn connected_event(&self) -> &impl Observable<PeerConnected>[src]

Returns a Single that emits a message when connected

pub fn disconnected_event(&self) -> &impl Observable<PeerDisconnected>[src]

Returns a Single that emits a message when connected

pub fn messages(&self) -> &impl Observable<PeerMessage>[src]

Returns an Observable that emits network messages

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

Returns whether the peer is connected

pub fn time_delta(&self) -> i64[src]

Returns the time difference in seconds between our time and theirs, which is valid after connecting

pub fn minfee(&self) -> u64[src]

Returns the minimum fee this peer accepts in sats/1000bytes

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

Returns whether this peer may announce new blocks with headers instead of inv

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

Returns whether compact blocks are supported

pub fn version(&self) -> Result<Version>[src]

Gets the version message received during the handshake

Trait Implementations

impl Debug for Peer[src]

impl Drop for Peer[src]

impl Eq for Peer[src]

impl Hash for Peer[src]

impl PartialEq<Peer> for Peer[src]

Auto Trait Implementations

impl RefUnwindSafe for Peer

impl Send for Peer

impl Sync for Peer

impl Unpin for Peer

impl UnwindSafe for Peer

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