Skip to main content

commonware_resolver/p2p/
config.rs

1use crate::{p2p::Producer, Consumer};
2use bytes::Bytes;
3use commonware_cryptography::PublicKey;
4use commonware_p2p::{Blocker, Provider};
5use commonware_utils::Span;
6use std::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, Failure = ()>,
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    /// The blocker that will be used to block peers that send invalid responses
23    pub blocker: B,
24
25    /// The consumer that gets notified when data is available
26    pub consumer: Con,
27
28    /// The producer that serves data requests
29    pub producer: Pro,
30
31    /// The maximum size of the mailbox backlog
32    pub mailbox_size: usize,
33
34    /// Local identity of the participant (if any).
35    pub me: Option<P>,
36
37    /// Initial expected performance for new participants.
38    pub initial: Duration,
39
40    /// Timeout for requests.
41    pub timeout: Duration,
42
43    /// How long fetches remain in the pending queue before being retried
44    pub fetch_retry_timeout: Duration,
45
46    /// Whether requests are sent with priority over other network messages
47    pub priority_requests: bool,
48
49    /// Whether responses are sent with priority over other network messages
50    pub priority_responses: bool,
51}