pub struct OutboundConnectionKeeper<Z: NetworkZone, A, C> {
pub new_peers_tx: Sender<Client<Z>>,
pub make_connection_rx: Receiver<MakeConnectionRequest>,
pub address_book_svc: A,
pub connector_svc: C,
pub outbound_semaphore: Arc<Semaphore>,
pub extra_peers: usize,
pub config: P2PConfig<Z>,
pub peer_type_gen: Bernoulli,
pub peer_sync_callback: Option<PeerSyncCallback>,
}Expand description
The outbound connection count keeper.
This handles maintaining a minimum number of connections and making extra connections when needed, upto a maximum.
Fields§
§new_peers_tx: Sender<Client<Z>>The pool of currently connected peers.
make_connection_rx: Receiver<MakeConnectionRequest>The channel that tells us to make new extra outbound connections.
address_book_svc: AThe address book service
connector_svc: CThe service to connect to a specific peer.
outbound_semaphore: Arc<Semaphore>A semaphore to keep the amount of outbound peers constant.
extra_peers: usizeThe amount of peers we connected to because we needed more peers. If the outbound_semaphore
is full, and we need to connect to more peers for blocks or because not enough peers are ready
we add a permit to the semaphore and keep track here, upto a value in config.
config: P2PConfig<Z>The p2p config.
peer_type_gen: BernoulliThe Bernoulli distribution, when sampled will return true if we should connect to a gray peer or
false if we should connect to a white peer.
This is weighted to the percentage given in config.
peer_sync_callback: Option<PeerSyncCallback>A callback used to notify the syncer about peer sync state changes.
Implementations§
Source§impl<Z, A, C> OutboundConnectionKeeper<Z, A, C>where
Z: NetworkZone,
A: AddressBook<Z>,
C: Service<ConnectRequest<Z>, Response = Client<Z>, Error = HandshakeError>,
C::Future: Send + 'static,
impl<Z, A, C> OutboundConnectionKeeper<Z, A, C>where
Z: NetworkZone,
A: AddressBook<Z>,
C: Service<ConnectRequest<Z>, Response = Client<Z>, Error = HandshakeError>,
C::Future: Send + 'static,
pub fn new( config: P2PConfig<Z>, new_peers_tx: Sender<Client<Z>>, make_connection_rx: Receiver<MakeConnectionRequest>, address_book_svc: A, connector_svc: C, peer_sync_callback: Option<PeerSyncCallback>, ) -> Self
Auto Trait Implementations§
impl<Z, A, C> !RefUnwindSafe for OutboundConnectionKeeper<Z, A, C>
impl<Z, A, C> !UnwindSafe for OutboundConnectionKeeper<Z, A, C>
impl<Z, A, C> Freeze for OutboundConnectionKeeper<Z, A, C>
impl<Z, A, C> Send for OutboundConnectionKeeper<Z, A, C>
impl<Z, A, C> Sync for OutboundConnectionKeeper<Z, A, C>
impl<Z, A, C> Unpin for OutboundConnectionKeeper<Z, A, C>
impl<Z, A, C> UnsafeUnpin for OutboundConnectionKeeper<Z, A, C>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.