pub struct Cache<N: Network> { /* private fields */ }
Implementations§
Source§impl<N: Network> Cache<N>
impl<N: Network> Cache<N>
Sourcepub fn insert_inbound_connection(
&self,
peer_ip: IpAddr,
interval_in_secs: i64,
) -> usize
pub fn insert_inbound_connection( &self, peer_ip: IpAddr, interval_in_secs: i64, ) -> usize
Inserts a new timestamp for the given peer connection, returning the number of recent connection requests.
Sourcepub fn insert_inbound_message(
&self,
peer_ip: SocketAddr,
interval_in_secs: i64,
) -> usize
pub fn insert_inbound_message( &self, peer_ip: SocketAddr, interval_in_secs: i64, ) -> usize
Inserts a new timestamp for the given peer message, returning the number of recent messages.
Sourcepub fn insert_inbound_puzzle_request(&self, peer_ip: SocketAddr) -> usize
pub fn insert_inbound_puzzle_request(&self, peer_ip: SocketAddr) -> usize
Inserts a new timestamp for the given peer IP, returning the number of recent requests.
Sourcepub fn insert_inbound_block_request(&self, peer_ip: SocketAddr) -> usize
pub fn insert_inbound_block_request(&self, peer_ip: SocketAddr) -> usize
Inserts a new timestamp for the given peer IP, returning the number of recent block requests.
Sourcepub fn insert_inbound_solution(
&self,
peer_ip: SocketAddr,
solution_id: SolutionID<N>,
) -> Option<OffsetDateTime>
pub fn insert_inbound_solution( &self, peer_ip: SocketAddr, solution_id: SolutionID<N>, ) -> Option<OffsetDateTime>
Inserts a solution ID into the cache, returning the previously seen timestamp if it existed.
Sourcepub fn insert_inbound_transaction(
&self,
peer_ip: SocketAddr,
transaction: N::TransactionID,
) -> Option<OffsetDateTime>
pub fn insert_inbound_transaction( &self, peer_ip: SocketAddr, transaction: N::TransactionID, ) -> Option<OffsetDateTime>
Inserts a transaction ID into the cache, returning the previously seen timestamp if it existed.
Source§impl<N: Network> Cache<N>
impl<N: Network> Cache<N>
Sourcepub fn contains_inbound_block_request(&self, peer_ip: &SocketAddr) -> bool
pub fn contains_inbound_block_request(&self, peer_ip: &SocketAddr) -> bool
Returns true
if the cache contains any inbound block requests for the given peer.
Sourcepub fn num_outbound_block_requests(&self, peer_ip: &SocketAddr) -> usize
pub fn num_outbound_block_requests(&self, peer_ip: &SocketAddr) -> usize
Returns the number of recent block requests for the given peer.
Sourcepub fn contains_outbound_block_request(
&self,
peer_ip: &SocketAddr,
request: &BlockRequest,
) -> bool
pub fn contains_outbound_block_request( &self, peer_ip: &SocketAddr, request: &BlockRequest, ) -> bool
Returns true
if the cache contains the given block request for the specified peer.
Sourcepub fn insert_outbound_block_request(
&self,
peer_ip: SocketAddr,
request: BlockRequest,
) -> usize
pub fn insert_outbound_block_request( &self, peer_ip: SocketAddr, request: BlockRequest, ) -> usize
Inserts the block request for the given peer IP, returning the number of recent requests.
Sourcepub fn remove_outbound_block_request(
&self,
peer_ip: SocketAddr,
request: &BlockRequest,
) -> bool
pub fn remove_outbound_block_request( &self, peer_ip: SocketAddr, request: &BlockRequest, ) -> bool
Removes the block request for the given peer IP, returning true
if the request was present.
Sourcepub fn contains_outbound_puzzle_request(&self, peer_ip: &SocketAddr) -> bool
pub fn contains_outbound_puzzle_request(&self, peer_ip: &SocketAddr) -> bool
Returns true
if the cache contains a puzzle request from the given peer.
Sourcepub fn increment_outbound_puzzle_requests(&self, peer_ip: SocketAddr) -> u32
pub fn increment_outbound_puzzle_requests(&self, peer_ip: SocketAddr) -> u32
Increment the peer IP’s number of puzzle requests, returning the updated number of puzzle requests.
Sourcepub fn decrement_outbound_puzzle_requests(&self, peer_ip: SocketAddr) -> u32
pub fn decrement_outbound_puzzle_requests(&self, peer_ip: SocketAddr) -> u32
Decrement the peer IP’s number of puzzle requests, returning the updated number of puzzle requests.
Sourcepub fn insert_outbound_solution(
&self,
peer_ip: SocketAddr,
solution_id: SolutionID<N>,
) -> Option<OffsetDateTime>
pub fn insert_outbound_solution( &self, peer_ip: SocketAddr, solution_id: SolutionID<N>, ) -> Option<OffsetDateTime>
Inserts a solution ID into the cache, returning the previously seen timestamp if it existed.
Sourcepub fn insert_outbound_transaction(
&self,
peer_ip: SocketAddr,
transaction: N::TransactionID,
) -> Option<OffsetDateTime>
pub fn insert_outbound_transaction( &self, peer_ip: SocketAddr, transaction: N::TransactionID, ) -> Option<OffsetDateTime>
Inserts a transaction ID into the cache, returning the previously seen timestamp if it existed.
Sourcepub fn contains_outbound_peer_request(&self, peer_ip: SocketAddr) -> bool
pub fn contains_outbound_peer_request(&self, peer_ip: SocketAddr) -> bool
Returns true
if the cache contains a peer request from the given peer.
Sourcepub fn increment_outbound_peer_requests(&self, peer_ip: SocketAddr) -> u32
pub fn increment_outbound_peer_requests(&self, peer_ip: SocketAddr) -> u32
Increment the peer IP’s number of peer requests, returning the updated number of peer requests.
Sourcepub fn decrement_outbound_peer_requests(&self, peer_ip: SocketAddr) -> u32
pub fn decrement_outbound_peer_requests(&self, peer_ip: SocketAddr) -> u32
Decrement the peer IP’s number of peer requests, returning the updated number of peer requests.
Sourcepub fn clear_peer_entries(&self, peer_ip: SocketAddr)
pub fn clear_peer_entries(&self, peer_ip: SocketAddr)
Removes all cache entries applicable to the given key.
Trait Implementations§
Auto Trait Implementations§
impl<N> !Freeze for Cache<N>
impl<N> !RefUnwindSafe for Cache<N>
impl<N> Send for Cache<N>
impl<N> Sync for Cache<N>
impl<N> Unpin for Cache<N>
impl<N> UnwindSafe for Cache<N>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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