commonware_resolver/p2p/config.rs
1use crate::{Consumer, p2p::Producer};
2use bytes::Bytes;
3use commonware_cryptography::PublicKey;
4use commonware_p2p::{Blocker, Provider};
5use commonware_utils::Span;
6use std::{num::NonZeroUsize, time::Duration};
7
8/// Configuration for the peer actor.
9pub struct Config<
10 P: PublicKey,
11 D: Provider<PublicKey = P>,
12 B: Blocker<PublicKey = P>,
13 Key: Span,
14 Con: Consumer<Key = Key, Value = Bytes>,
15 Pro: Producer<Key = Key>,
16> {
17 /// Manages the current set of peers.
18 ///
19 /// Peer selection for outbound fetches is documented in the [`p2p`](crate::p2p) module.
20 pub peer_provider: D,
21
22 /// Blocks peers that send invalid responses and reports which peers are
23 /// currently blocked.
24 pub blocker: B,
25
26 /// The consumer that gets notified when data is available
27 pub consumer: Con,
28
29 /// The producer that serves data requests
30 pub producer: Pro,
31
32 /// The maximum size of the mailbox backlog
33 pub mailbox_size: NonZeroUsize,
34
35 /// Local identity of the participant (if any).
36 pub me: Option<P>,
37
38 /// Timeout for requests.
39 pub timeout: Duration,
40
41 /// How long fetches remain in the pending queue before being retried
42 pub fetch_retry_timeout: Duration,
43
44 /// Whether requests are sent with priority over other network messages
45 pub priority_requests: bool,
46
47 /// Whether responses are sent with priority over other network messages
48 pub priority_responses: bool,
49}