rostra-client 0.1.3

Integration runtime for Rostra peer-to-peer clients
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Bounded network operations for background maintenance workers.

use std::future::Future;
use std::time::Duration;

/// Maximum time a maintenance worker gives one peer operation.
pub(crate) const PEER_OPERATION_DEADLINE: Duration = Duration::from_secs(30);

/// Maximum time one Web-of-Trust repair sweep may occupy its worker.
pub(crate) const WOT_SYNC_CYCLE_DEADLINE: Duration = Duration::from_secs(30 * 60);

/// Run an operation until its worker-specific deadline expires.
pub(crate) async fn within<T>(
    deadline: Duration,
    operation: impl Future<Output = T>,
) -> Result<T, tokio::time::error::Elapsed> {
    tokio::time::timeout(deadline, operation).await
}