1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::{Consumer, p2p::Producer};
use bytes::Bytes;
use commonware_cryptography::PublicKey;
use commonware_p2p::{Blocker, Provider};
use commonware_utils::{NonZeroDuration, Span};
use std::{num::NonZeroUsize, time::Duration};
/// Configuration for the peer actor.
pub struct Config<
P: PublicKey,
D: Provider<PublicKey = P>,
B: Blocker<PublicKey = P>,
Key: Span,
Con: Consumer<Key = Key, Value = Bytes>,
Pro: Producer<Key = Key>,
> {
/// Manages the current set of peers.
///
/// Peer selection for outbound fetches is documented in the [`p2p`](crate::p2p) module.
pub peer_provider: D,
/// Blocks peers that send invalid responses and reports which peers are
/// currently blocked.
pub blocker: B,
/// The consumer that gets notified when data is available
pub consumer: Con,
/// The producer that serves data requests
pub producer: Pro,
/// The maximum size of the mailbox backlog
pub mailbox_size: NonZeroUsize,
/// Local identity of the participant (if any).
pub me: Option<P>,
/// Maximum wait for a response.
pub fetch_timeout: NonZeroDuration,
/// Delay after an unresolved attempt before retrying its fetch.
/// Zero permits immediate retries, subject to the sender's rate limit.
pub fetch_retry_delay: Duration,
/// Whether requests are sent with priority over other network messages
pub priority_requests: bool,
/// Whether responses are sent with priority over other network messages
pub priority_responses: bool,
}