soil_network/mixnet/config.rs
1// This file is part of Soil.
2
3// Copyright (C) Soil contributors.
4// Copyright (C) Parity Technologies (UK) Ltd.
5// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
6
7pub use mixnet::core::Config as CoreConfig;
8use std::time::Duration;
9
10/// Substrate-specific mixnet configuration.
11#[derive(Clone, Debug)]
12pub struct SubstrateConfig {
13 /// Attempt to register the local node as a mixnode?
14 pub register: bool,
15 /// Maximum number of incoming mixnet connections to accept from non-mixnodes. If the local
16 /// node will never be a mixnode, this can be set to 0.
17 pub num_gateway_slots: u32,
18
19 /// Number of requests to the mixnet service that can be buffered, in addition to the one per
20 /// [`Api`](super::api::Api) instance. Note that this does not include requests that are being
21 /// actively handled.
22 pub request_buffer: usize,
23 /// Used to determine the number of SURBs to include in request messages: the maximum number of
24 /// SURBs needed for a single reply is multiplied by this. This should not be set to 0.
25 pub surb_factor: usize,
26
27 /// Maximum number of submit extrinsic requests waiting for their delay to elapse. When at the
28 /// limit, any submit extrinsic requests that arrive will simply be dropped.
29 pub extrinsic_queue_capacity: usize,
30 /// Mean delay between receiving a submit extrinsic request and actually submitting the
31 /// extrinsic. This should really be the same for all nodes!
32 pub mean_extrinsic_delay: Duration,
33 /// Maximum number of extrinsics being actively submitted. If a submit extrinsic request's
34 /// delay elapses and we are already at this limit, the request will simply be dropped.
35 pub max_pending_extrinsics: usize,
36}
37
38impl Default for SubstrateConfig {
39 fn default() -> Self {
40 Self {
41 register: true,
42 num_gateway_slots: 150,
43
44 request_buffer: 4,
45 surb_factor: 2,
46
47 extrinsic_queue_capacity: 50,
48 mean_extrinsic_delay: Duration::from_secs(1),
49 max_pending_extrinsics: 20,
50 }
51 }
52}
53
54/// Mixnet configuration.
55#[derive(Clone, Debug)]
56pub struct Config {
57 /// Core configuration.
58 pub core: CoreConfig,
59 /// Request manager configuration.
60 pub request_manager: mixnet::request_manager::Config,
61 /// Reply manager configuration.
62 pub reply_manager: mixnet::reply_manager::Config,
63 /// Substrate-specific configuration.
64 pub substrate: SubstrateConfig,
65}
66
67impl Default for Config {
68 fn default() -> Self {
69 Self {
70 core: Default::default(),
71 request_manager: Default::default(),
72 reply_manager: Default::default(),
73 substrate: Default::default(),
74 }
75 }
76}