ant_protocol/
constants.rs

1// Copyright 2025 MaidSafe.net limited.
2//
3// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
4// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
5// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6// KIND, either express or implied. Please review the Licences for the specific language governing
7// permissions and limitations relating to use of the SAFE Network Software.
8
9use std::num::NonZeroUsize;
10
11/// What is the largest packet to send over the network.
12pub const MAX_PACKET_SIZE: usize = 1024 * 1024 * 5;
13
14/// The maximum number of peers to return in a `GetClosestPeers` response.
15/// This is the group size used in safe network protocol to be responsible for
16/// an item in the network.
17/// The peer should be present among the CLOSE_GROUP_SIZE if we're fetching the close_group(peer)
18/// The size has been set to 5 for improved performance.
19pub const CLOSE_GROUP_SIZE: usize = 5;
20
21/// The protocol ID for the Kademlia stream
22pub const KAD_STREAM_PROTOCOL_ID: &str = "/autonomi/kad/1.0.0";
23
24/// The maximum size of a record
25pub const MAX_RECORD_SIZE: usize = 1024 * 1024 * 4;
26
27/// The replication factor we use on the network
28/// Libp2p queries all depend on this, for quorum and others
29/// Is defined as CLOSE_GROUP_SIZE + 2
30pub const REPLICATION_FACTOR: NonZeroUsize =
31    NonZeroUsize::new(7).expect("REPLICATION_FACTOR must be 7");