cuprate_constants/
rpc.rs

1//! RPC related.
2
3use core::time::Duration;
4
5use crate::macros::monero_definition_link;
6
7/// Maximum requestable block header range.
8#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/rpc/core_rpc_server.cpp", 74)]
9///
10/// This is the maximum amount of blocks that can be requested
11/// per invocation of `get_block_headers` if the RPC server is
12/// in restricted mode.
13///
14/// Used at:
15/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L2593>
16pub const RESTRICTED_BLOCK_HEADER_RANGE: u64 = 1000;
17
18/// Maximum requestable transaction count.
19#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/rpc/core_rpc_server.cpp", 75)]
20///
21/// This is the maximum amount of transactions that can be requested
22/// per invocation of `get_transactions` and `get_indexes` if the
23/// RPC server is in restricted mode.
24///
25/// Used at:
26/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L660>
27/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L998>
28pub const RESTRICTED_TRANSACTIONS_COUNT: usize = 100;
29
30/// Maximum amount of requestable key image checks.
31#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/rpc/core_rpc_server.cpp", 76)]
32///
33/// This is the maximum amount of key images that can be requested
34/// to be checked per `/is_key_image_spent` call if the RPC server
35/// is in restricted mode.
36///
37/// Used at:
38/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L1248>
39/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L3570>
40pub const RESTRICTED_SPENT_KEY_IMAGES_COUNT: usize = 5000;
41
42/// Maximum amount of requestable blocks.
43#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/rpc/core_rpc_server.cpp", 77)]
44///
45/// This is the maximum amount of blocks that can be
46/// requested if the RPC server is in restricted mode.
47///
48/// Used at:
49/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L834>
50/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L2519>
51pub const RESTRICTED_BLOCK_COUNT: usize = 1000;
52
53/// Maximum amount of fake outputs.
54#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/rpc/core_rpc_server.cpp", 67)]
55///
56/// This is the maximum amount of outputs that can be
57/// requested if the RPC server is in restricted mode.
58///
59/// Used at:
60/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L905>
61/// - <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L935>
62pub const MAX_RESTRICTED_GLOBAL_FAKE_OUTS_COUNT: usize = 5000;
63
64/// Maximum output histrogram cutoff.
65#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/rpc/core_rpc_server.cpp", 69)]
66///
67/// This is the maximum cutoff duration allowed in `get_output_histogram` (3 days).
68///
69/// ```rust
70/// # use cuprate_constants::rpc::*;
71/// assert_eq!(OUTPUT_HISTOGRAM_RECENT_CUTOFF_RESTRICTION.as_secs(), 86_400 * 3);
72/// ```
73///
74/// Used at:
75/// <https://github.com/monero-project/monero/blob/a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623/src/rpc/core_rpc_server.cpp#L2961>
76pub const OUTPUT_HISTOGRAM_RECENT_CUTOFF_RESTRICTION: Duration = Duration::from_secs(86400 * 3);
77
78/// Maximum amount of requestable blocks in `/get_blocks.bin`.
79#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 128)]
80pub const GET_BLOCKS_BIN_MAX_BLOCK_COUNT: u64 = 1000;
81
82/// Maximum amount of requestable transactions in `/get_blocks.bin`.
83#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 129)]
84pub const GET_BLOCKS_BIN_MAX_TX_COUNT: u64 = 20_000;
85
86/// Max message content length in the RPC server.
87#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 130)]
88///
89/// This is the maximum amount of bytes an HTTP request
90/// body can be before the RPC server rejects it (1 megabyte).
91pub const MAX_RPC_CONTENT_LENGTH: u64 = 1_048_576;
92
93/// Amount of fails before blocking a remote RPC server.
94#[doc = monero_definition_link!(a1dc85c5373a30f14aaf7dcfdd95f5a7375d3623, "/src/cryptonote_config.h", 159)]
95///
96/// This is the amount of times an RPC will attempt to
97/// connect to another remote IP before blocking it.
98///
99/// RPC servers connect to nodes when they themselves
100/// lack the data to fulfill the response.
101pub const RPC_IP_FAILS_BEFORE_BLOCK: u64 = 3;