nautilus_blockchain/config.rs
1// -------------------------------------------------------------------------------------------------
2// Copyright (C) 2015-2025 Posei Systems Pty Ltd. All rights reserved.
3// https://poseitrader.io
4//
5// Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6// You may not use this file except in compliance with the License.
7// You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16use std::sync::Arc;
17
18use nautilus_model::defi::Chain;
19
20/// Configuration for blockchain data clients.
21#[derive(Debug, Clone)]
22pub struct BlockchainDataClientConfig {
23 /// The blockchain chain configuration.
24 pub chain: Arc<Chain>,
25 /// Determines if the client should use Hypersync for live data streaming.
26 pub use_hypersync_for_live_data: bool,
27 /// The HTTP URL for the blockchain RPC endpoint.
28 pub http_rpc_url: String,
29 /// The maximum number of RPC requests allowed per second.
30 pub rpc_requests_per_second: Option<u32>,
31 /// The WebSocket secure URL for the blockchain RPC endpoint.
32 pub wss_rpc_url: Option<String>,
33 /// The block from which to sync historical data.
34 pub from_block: Option<u64>,
35}
36
37impl BlockchainDataClientConfig {
38 /// Creates a new [`BlockchainDataClientConfig`] instance.
39 #[must_use]
40 pub const fn new(
41 chain: Arc<Chain>,
42 http_rpc_url: String,
43 rpc_requests_per_second: Option<u32>,
44 wss_rpc_url: Option<String>,
45 use_hypersync_for_live_data: bool,
46 from_block: Option<u64>,
47 ) -> Self {
48 Self {
49 chain,
50 use_hypersync_for_live_data,
51 http_rpc_url,
52 rpc_requests_per_second,
53 wss_rpc_url,
54 from_block,
55 }
56 }
57}