reth_node_core/args/
static_files.rs

1//! clap [Args](clap::Args) for static files configuration
2
3use clap::Args;
4use reth_config::config::{BlocksPerFileConfig, StaticFilesConfig};
5use reth_provider::StorageSettings;
6
7/// Parameters for static files configuration
8#[derive(Debug, Args, PartialEq, Eq, Default, Clone, Copy)]
9#[command(next_help_heading = "Static Files")]
10pub struct StaticFilesArgs {
11    /// Number of blocks per file for the headers segment.
12    #[arg(long = "static-files.blocks-per-file.headers")]
13    pub blocks_per_file_headers: Option<u64>,
14
15    /// Number of blocks per file for the transactions segment.
16    #[arg(long = "static-files.blocks-per-file.transactions")]
17    pub blocks_per_file_transactions: Option<u64>,
18
19    /// Number of blocks per file for the receipts segment.
20    #[arg(long = "static-files.blocks-per-file.receipts")]
21    pub blocks_per_file_receipts: Option<u64>,
22
23    /// Number of blocks per file for the transaction senders segment.
24    #[arg(long = "static-files.blocks-per-file.transaction-senders")]
25    pub blocks_per_file_transaction_senders: Option<u64>,
26
27    /// Store receipts in static files instead of the database.
28    ///
29    /// When enabled, receipts will be written to static files on disk instead of the database.
30    ///
31    /// Note: This setting can only be configured at genesis initialization. Once
32    /// the node has been initialized, changing this flag requires re-syncing from scratch.
33    #[arg(long = "static-files.receipts")]
34    pub receipts: bool,
35
36    /// Store transaction senders in static files instead of the database.
37    ///
38    /// When enabled, transaction senders will be written to static files on disk instead of the
39    /// database.
40    ///
41    /// Note: This setting can only be configured at genesis initialization. Once
42    /// the node has been initialized, changing this flag requires re-syncing from scratch.
43    #[arg(long = "static-files.transaction-senders")]
44    pub transaction_senders: bool,
45}
46
47impl StaticFilesArgs {
48    /// Merges the CLI arguments with an existing [`StaticFilesConfig`], giving priority to CLI
49    /// args.
50    pub fn merge_with_config(&self, config: StaticFilesConfig) -> StaticFilesConfig {
51        StaticFilesConfig {
52            blocks_per_file: BlocksPerFileConfig {
53                headers: self.blocks_per_file_headers.or(config.blocks_per_file.headers),
54                transactions: self
55                    .blocks_per_file_transactions
56                    .or(config.blocks_per_file.transactions),
57                receipts: self.blocks_per_file_receipts.or(config.blocks_per_file.receipts),
58                transaction_senders: self
59                    .blocks_per_file_transaction_senders
60                    .or(config.blocks_per_file.transaction_senders),
61            },
62        }
63    }
64
65    /// Converts the static files arguments into [`StorageSettings`].
66    pub const fn to_settings(&self) -> StorageSettings {
67        StorageSettings::legacy()
68            .with_receipts_in_static_files(self.receipts)
69            .with_transaction_senders_in_static_files(self.transaction_senders)
70    }
71}