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
16/// Configuration for blockchain adapter connections.
17#[derive(Debug, Clone)]
18pub struct BlockchainAdapterConfig {
19    /// Determines if the adapter should use Hypersync for live data streaming.
20    pub use_hypersync_for_live_data: bool,
21    /// The HTTP URL for the blockchain RPC endpoint.
22    pub http_rpc_url: String,
23    /// The maximum number of RPC requests allowed per second.
24    pub rpc_requests_per_second: Option<u32>,
25    /// The WebSocket secure URL for the blockchain RPC endpoint.
26    pub wss_rpc_url: Option<String>,
27}
28
29impl BlockchainAdapterConfig {
30    /// Creates a new [`BlockchainAdapterConfig`] instance.
31    #[must_use]
32    pub const fn new(
33        http_rpc_url: String,
34        rpc_requests_per_second: Option<u32>,
35        wss_rpc_url: Option<String>,
36        use_hypersync_for_live_data: bool,
37    ) -> Self {
38        Self {
39            use_hypersync_for_live_data,
40            http_rpc_url,
41            rpc_requests_per_second,
42            wss_rpc_url,
43        }
44    }
45}