mixnet/request_manager/
config.rs

1// Copyright 2022 Parity Technologies (UK) Ltd.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a
4// copy of this software and associated documentation files (the "Software"),
5// to deal in the Software without restriction, including without limitation
6// the rights to use, copy, modify, merge, publish, distribute, sublicense,
7// and/or sell copies of the Software, and to permit persons to whom the
8// Software is furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19// DEALINGS IN THE SOFTWARE.
20
21/// Request manager configuration.
22#[derive(Clone, Debug)]
23pub struct Config {
24	/// Maximum number of requests that can be managed at once.
25	pub capacity: usize,
26
27	/// Number of destinations to try sending a request to before giving up. Note that the
28	/// destinations are chosen randomly with replacement; the same destination might be chosen
29	/// multiple times.
30	pub num_destinations: u32,
31	/// Number of times to attempt a destination before moving on to the next. After each attempt,
32	/// we conservatively estimate the round-trip time and wait at least this long before the next
33	/// attempt. Must not be 0.
34	pub num_attempts_per_destination: u32,
35	/// Number of copies of the message to post each time we send a request. Must not be 0.
36	pub num_posts_per_attempt: u32,
37}
38
39impl Default for Config {
40	fn default() -> Self {
41		Self {
42			capacity: 20,
43
44			num_destinations: 3,
45			num_attempts_per_destination: 2,
46			num_posts_per_attempt: 2,
47		}
48	}
49}