Compare commits

...

1 Commits

Author SHA1 Message Date
junderw
f02b103f75
Allow config for skipping compaction 2024-12-15 21:24:41 +09:00
2 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,7 @@ pub struct Config {
pub utxos_limit: usize,
pub electrum_txs_limit: usize,
pub electrum_banner: String,
pub skip_compaction: bool,
pub mempool_backlog_stats_ttl: u64,
pub mempool_recent_txs_size: usize,
pub rest_default_block_limit: usize,
@ -276,6 +277,10 @@ impl Config {
.long("electrum-banner")
.help("Welcome banner for the Electrum server, shown in the console to clients.")
.takes_value(true)
).arg(
Arg::with_name("skip_compaction")
.long("skip-compaction")
.help("Skip compactions after initial sync")
);
#[cfg(unix)]
@ -517,6 +522,7 @@ impl Config {
electrum_rpc_addr,
electrum_txs_limit: value_t_or_exit!(m, "electrum_txs_limit", usize),
electrum_banner,
skip_compaction: m.is_present("skip_compaction"),
http_addr,
http_socket_file,
rpc_socket_file,

View File

@ -183,6 +183,7 @@ struct IndexerConfig {
light_mode: bool,
address_search: bool,
index_unspendables: bool,
skip_compaction: bool,
network: Network,
#[cfg(feature = "liquid")]
parent_network: crate::chain::BNetwork,
@ -195,6 +196,7 @@ impl From<&Config> for IndexerConfig {
address_search: config.address_search,
index_unspendables: config.index_unspendables,
network: config.network_type,
skip_compaction: config.skip_compaction,
#[cfg(feature = "liquid")]
parent_network: config.parent_network,
}
@ -250,7 +252,9 @@ impl Indexer {
fn start_auto_compactions(&self, db: &DB) {
let key = b"F".to_vec();
if db.get(&key).is_none() {
db.full_compaction();
if !self.iconfig.skip_compaction {
db.full_compaction();
}
db.put_sync(&key, b"");
assert!(db.get(&key).is_some());
}