Trait bip_utracker::Handshaker
[−]
pub trait Handshaker: Send { type Stream; fn id(&self) -> ShaHash; fn port(&self) -> u16; fn connect(&mut self, expected: Option<ShaHash>, hash: ShaHash, addr: SocketAddr); fn filter<F>(&mut self, process: Box<F>) where F: Fn(&SocketAddr) -> bool + Send; fn stream(&self, hash: ShaHash) -> Self::Stream; }
Trait for providing a handshaker object with connection information.
Associated Types
type Stream
Type of stream used to receive connections from.
Required Methods
fn id(&self) -> ShaHash
Unique PeerId used to identify ourselves to other peers.
fn port(&self) -> u16
Advertise port that is being listened on by the handshaker.
It is important that this is the external port that the peer will be sending data to. This is relevant if the client employs nat traversal via upnp or other means.
fn connect(&mut self, expected: Option<ShaHash>, hash: ShaHash, addr: SocketAddr)
Initiates a handshake with the given socket address for the given InfoHash.
fn filter<F>(&mut self, process: Box<F>) where F: Fn(&SocketAddr) -> bool + Send
Adds a filter that is applied to handshakes before they are initiated or completed.
fn stream(&self, hash: ShaHash) -> Self::Stream
Stream that connections for the specified hash are sent to after they are successful.
Connections MAY be dropped if all streams for a given hash are not active.
Implementors
impl<T> Handshaker for BTHandshaker<T> where T: Send