pub struct TcpPeerManager { /* private fields */ }Expand description
TCP-based Bitcoin P2P peer manager.
Manages outbound connections, performs version/verack handshakes, tracks misbehaviour, and broadcasts blocks and transactions.
Implementations§
Source§impl TcpPeerManager
impl TcpPeerManager
Sourcepub fn new(local_addr: SocketAddr) -> Self
pub fn new(local_addr: SocketAddr) -> Self
Create a new TCP peer manager
Sourcepub async fn set_height(&self, height: u32)
pub async fn set_height(&self, height: u32)
Update the current chain height (used in version messages)
Sourcepub async fn peer_count(&self) -> usize
pub async fn peer_count(&self) -> usize
Get count of connected peers
Sourcepub async fn add_misbehaviour(&self, peer_id: u64, score: i32)
pub async fn add_misbehaviour(&self, peer_id: u64, score: i32)
Increase a peer’s misbehaviour score; ban if threshold exceeded
Trait Implementations§
Source§impl Default for TcpPeerManager
impl Default for TcpPeerManager
Source§impl PeerManager for TcpPeerManager
impl PeerManager for TcpPeerManager
Source§fn connect_peer<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect_peer<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initiates a connection to a peer. Read more
Source§fn disconnect_peer<'life0, 'async_trait>(
&'life0 self,
peer_id: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect_peer<'life0, 'async_trait>(
&'life0 self,
peer_id: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disconnects from a peer. Read more
Source§fn ban_peer<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
ban_time: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ban_peer<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
ban_time: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Bans a peer, preventing further connections. Read more
Source§fn get_connected_peers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PeerInfo>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_connected_peers<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<PeerInfo>, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Gets information about all connected peers. Read more
Source§fn broadcast_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 Transaction,
) -> Pin<Box<dyn Future<Output = Result<usize, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn broadcast_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
tx: &'life1 Transaction,
) -> Pin<Box<dyn Future<Output = Result<usize, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Broadcasts a transaction to all connected peers. Read more
Source§fn broadcast_block<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block,
) -> Pin<Box<dyn Future<Output = Result<usize, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn broadcast_block<'life0, 'life1, 'async_trait>(
&'life0 self,
block: &'life1 Block,
) -> Pin<Box<dyn Future<Output = Result<usize, Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Broadcasts a block to all connected peers. Read more
Auto Trait Implementations§
impl !Freeze for TcpPeerManager
impl !RefUnwindSafe for TcpPeerManager
impl Send for TcpPeerManager
impl Sync for TcpPeerManager
impl Unpin for TcpPeerManager
impl UnsafeUnpin for TcpPeerManager
impl !UnwindSafe for TcpPeerManager
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
Mutably borrows from an owned value. Read more