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 /// Number of blocks per file for the account changesets segment.
28 #[arg(long = "static-files.blocks-per-file.account-change-sets")]
29 pub blocks_per_file_account_change_sets: Option<u64>,
30
31 /// Store receipts in static files instead of the database.
32 ///
33 /// When enabled, receipts will be written to static files on disk instead of the database.
34 ///
35 /// Note: This setting can only be configured at genesis initialization. Once
36 /// the node has been initialized, changing this flag requires re-syncing from scratch.
37 #[arg(long = "static-files.receipts")]
38 pub receipts: bool,
39
40 /// Store transaction senders in static files instead of the database.
41 ///
42 /// When enabled, transaction senders will be written to static files on disk instead of the
43 /// database.
44 ///
45 /// Note: This setting can only be configured at genesis initialization. Once
46 /// the node has been initialized, changing this flag requires re-syncing from scratch.
47 #[arg(long = "static-files.transaction-senders")]
48 pub transaction_senders: bool,
49
50 /// Store account changesets in static files.
51 ///
52 /// When enabled, account changesets will be written to static files on disk instead of the
53 /// database.
54 ///
55 /// Note: This setting can only be configured at genesis initialization. Once
56 /// the node has been initialized, changing this flag requires re-syncing from scratch.
57 #[arg(long = "static-files.account-change-sets")]
58 pub account_changesets: bool,
59}
60
61impl StaticFilesArgs {
62 /// Merges the CLI arguments with an existing [`StaticFilesConfig`], giving priority to CLI
63 /// args.
64 pub fn merge_with_config(&self, config: StaticFilesConfig) -> StaticFilesConfig {
65 StaticFilesConfig {
66 blocks_per_file: BlocksPerFileConfig {
67 headers: self.blocks_per_file_headers.or(config.blocks_per_file.headers),
68 transactions: self
69 .blocks_per_file_transactions
70 .or(config.blocks_per_file.transactions),
71 receipts: self.blocks_per_file_receipts.or(config.blocks_per_file.receipts),
72 transaction_senders: self
73 .blocks_per_file_transaction_senders
74 .or(config.blocks_per_file.transaction_senders),
75 account_change_sets: self
76 .blocks_per_file_account_change_sets
77 .or(config.blocks_per_file.account_change_sets),
78 },
79 }
80 }
81
82 /// Converts the static files arguments into [`StorageSettings`].
83 pub const fn to_settings(&self) -> StorageSettings {
84 StorageSettings::legacy()
85 .with_receipts_in_static_files(self.receipts)
86 .with_transaction_senders_in_static_files(self.transaction_senders)
87 .with_account_changesets_in_static_files(self.account_changesets)
88 }
89}