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::{NonZeroDuration, 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 /// Maximum wait for a response.
39 pub fetch_timeout: NonZeroDuration,
40
41 /// Delay after an unresolved attempt before retrying its fetch.
42 /// Zero permits immediate retries, subject to the sender's rate limit.
43 pub fetch_retry_delay: Duration,
44
45 /// Whether requests are sent with priority over other network messages
46 pub priority_requests: bool,
47
48 /// Whether responses are sent with priority over other network messages
49 pub priority_responses: bool,
50}