Struct bdk::blockchain::compact_filters::Peer
source · pub struct Peer { /* private fields */ }
compact_filters
only.Expand description
A Bitcoin peer
Implementations
sourceimpl Peer
impl Peer
sourcepub fn connect<A: ToSocketAddrs>(
address: A,
mempool: Arc<Mempool>,
network: Network
) -> Result<Self, CompactFiltersError>
pub fn connect<A: ToSocketAddrs>(
address: A,
mempool: Arc<Mempool>,
network: Network
) -> Result<Self, CompactFiltersError>
Connect to a peer over a plaintext TCP connection
This function internally spawns a new thread that will monitor incoming messages from the peer, and optionally reply to some of them transparently, like pings
sourcepub fn connect_proxy<T: ToTargetAddr, P: ToSocketAddrs>(
target: T,
proxy: P,
credentials: Option<(&str, &str)>,
mempool: Arc<Mempool>,
network: Network
) -> Result<Self, CompactFiltersError>
pub fn connect_proxy<T: ToTargetAddr, P: ToSocketAddrs>(
target: T,
proxy: P,
credentials: Option<(&str, &str)>,
mempool: Arc<Mempool>,
network: Network
) -> Result<Self, CompactFiltersError>
Connect to a peer through a SOCKS5 proxy, optionally by using some credentials, specified
as a tuple of (username, password)
This function internally spawns a new thread that will monitor incoming messages from the peer, and optionally reply to some of them transparently, like pings
sourcepub fn get_version(&self) -> &VersionMessage
pub fn get_version(&self) -> &VersionMessage
Return the VersionMessage
sent by the peer
sourcepub fn get_network(&self) -> Network
pub fn get_network(&self) -> Network
Return the Bitcoin Network
in use
sourcepub fn get_mempool(&self) -> Arc<Mempool>
pub fn get_mempool(&self) -> Arc<Mempool>
Return the mempool used by this peer
sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Return whether or not the peer is still connected
sourcepub fn send(&self, payload: NetworkMessage) -> Result<(), CompactFiltersError>
pub fn send(&self, payload: NetworkMessage) -> Result<(), CompactFiltersError>
Send a raw Bitcoin message to the peer
sourcepub fn recv(
&self,
wait_for: &'static str,
timeout: Option<Duration>
) -> Result<Option<NetworkMessage>, CompactFiltersError>
pub fn recv(
&self,
wait_for: &'static str,
timeout: Option<Duration>
) -> Result<Option<NetworkMessage>, CompactFiltersError>
Waits for a specific incoming Bitcoin message, optionally with a timeout