pub struct RefreshService {
table: Arc<RoutingTable>,
listen_endpoint: Option<Endpoint>,
task_group: TaskGroup,
config: Arc<Config>,
monitor: Arc<Monitor>,
}Fields§
§table: Arc<RoutingTable>Routing table
listen_endpoint: Option<Endpoint>UDP listen endpoint (None when no udp discovery endpoint is configured).
task_group: TaskGroupManaging spawned tasks.
config: Arc<Config>Holds the configuration for the P2P network.
monitor: Arc<Monitor>Responsible for network and system monitoring.
Implementations§
Source§impl RefreshService
impl RefreshService
Sourcepub fn new(
config: Arc<Config>,
table: Arc<RoutingTable>,
monitor: Arc<Monitor>,
listen_endpoint: Option<Endpoint>,
executor: Executor,
) -> Self
pub fn new( config: Arc<Config>, table: Arc<RoutingTable>, monitor: Arc<Monitor>, listen_endpoint: Option<Endpoint>, executor: Executor, ) -> Self
Creates a new refresh service
Sourceasync fn refresh_loop(self: Arc<Self>) -> Result<()>
async fn refresh_loop(self: Arc<Self>) -> Result<()>
Periodically refresh the routing table by pinging the oldest entries.
Sourceasync fn do_refresh(self: Arc<Self>, entries: &[BucketEntry]) -> usize
async fn do_refresh(self: Arc<Self>, entries: &[BucketEntry]) -> usize
Iterates over the entries and initiates a connection. Returns the number of entries refreshed successfully.
Sourceasync fn refresh_entry(self: Arc<Self>, bucket_entry: BucketEntry) -> bool
async fn refresh_entry(self: Arc<Self>, bucket_entry: BucketEntry) -> bool
Refresh a specific entry by pinging it over UDP. Returns true if the ping succeeded.
Sourceasync fn listen_loop(self: Arc<Self>, endpoint: Endpoint) -> Result<()>
async fn listen_loop(self: Arc<Self>, endpoint: Endpoint) -> Result<()>
Listen on UDP for Ping messages.
Sourceasync fn listen_to_ping_msg(
&self,
conn: &UdpConn,
rate_limiter: &mut HashMap<IpAddr, RateBucket>,
) -> Result<()>
async fn listen_to_ping_msg( &self, conn: &UdpConn, rate_limiter: &mut HashMap<IpAddr, RateBucket>, ) -> Result<()>
Listen for a Ping message and respond with a Pong message. Drops pings from sources not in the routing table or that exceed the per-IP rate limit.
Sourceasync fn send_ping_msg(
&self,
conn: &UdpConn,
peer_addr: SocketAddr,
) -> Result<()>
async fn send_ping_msg( &self, conn: &UdpConn, peer_addr: SocketAddr, ) -> Result<()>
Sends a Ping msg and waits for the Pong response.
Auto Trait Implementations§
impl !Freeze for RefreshService
impl !RefUnwindSafe for RefreshService
impl Send for RefreshService
impl Sync for RefreshService
impl Unpin for RefreshService
impl UnsafeUnpin for RefreshService
impl !UnwindSafe for RefreshService
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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