avoid starting the scan task if no keys to scan are present (#8059)
This commit is contained in:
parent
73b3ed1f9f
commit
cdfbecf5f5
|
@ -289,8 +289,8 @@ impl StartCmd {
|
|||
let syncer_task_handle = tokio::spawn(syncer.sync().in_current_span());
|
||||
|
||||
#[cfg(feature = "shielded-scan")]
|
||||
// Spawn never ending scan task.
|
||||
let scan_task_handle = {
|
||||
// Spawn never ending scan task only if we have keys to scan for.
|
||||
let scan_task_handle = if !config.shielded_scan.sapling_keys_to_scan.is_empty() {
|
||||
// TODO: log the number of keys and update the scan_task_starts() test
|
||||
info!("spawning shielded scanner with configured viewing keys");
|
||||
zebra_scan::spawn_init(
|
||||
|
@ -299,6 +299,8 @@ impl StartCmd {
|
|||
state,
|
||||
chain_tip_change,
|
||||
)
|
||||
} else {
|
||||
tokio::spawn(std::future::pending().in_current_span())
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "shielded-scan"))]
|
||||
|
|
|
@ -204,6 +204,9 @@ pub const MAX_ASYNC_BLOCKING_TIME: Duration = zebra_test::mock_service::DEFAULT_
|
|||
/// The test config file prefix for `--feature getblocktemplate-rpcs` configs.
|
||||
pub const GET_BLOCK_TEMPLATE_CONFIG_PREFIX: &str = "getblocktemplate-";
|
||||
|
||||
/// The test config file prefix for `--feature shielded-scan` configs.
|
||||
pub const SHIELDED_SCAN_CONFIG_PREFIX: &str = "shieldedscan-";
|
||||
|
||||
#[test]
|
||||
fn generate_no_args() -> Result<()> {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
@ -806,18 +809,18 @@ fn last_config_is_stored() -> Result<()> {
|
|||
zebrad generate | \n\
|
||||
sed 's/cache_dir = \".*\"/cache_dir = \"cache_dir\"/' > \n\
|
||||
zebrad/tests/common/configs/{}<next-release-tag>.toml",
|
||||
if cfg!(feature = "getblocktemplate-rpcs") {
|
||||
GET_BLOCK_TEMPLATE_CONFIG_PREFIX
|
||||
if cfg!(feature = "shielded-scan") {
|
||||
SHIELDED_SCAN_CONFIG_PREFIX
|
||||
} else {
|
||||
""
|
||||
},
|
||||
if cfg!(feature = "getblocktemplate-rpcs") {
|
||||
"--features=getblocktemplate-rpcs "
|
||||
if cfg!(feature = "shielded-scan") {
|
||||
"--features=shielded-scan "
|
||||
} else {
|
||||
""
|
||||
},
|
||||
if cfg!(feature = "getblocktemplate-rpcs") {
|
||||
GET_BLOCK_TEMPLATE_CONFIG_PREFIX
|
||||
if cfg!(feature = "shielded-scan") {
|
||||
SHIELDED_SCAN_CONFIG_PREFIX
|
||||
} else {
|
||||
""
|
||||
},
|
||||
|
@ -946,6 +949,14 @@ fn stored_configs_work() -> Result<()> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// ignore files starting with shieldedscan prefix
|
||||
// if we were not built with the shielded-scan feature.
|
||||
#[cfg(not(feature = "shielded-scan"))]
|
||||
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
||||
tracing::info!(?config_file_path, "skipping shielded-scan config file path");
|
||||
continue;
|
||||
}
|
||||
|
||||
let run_dir = testdir()?;
|
||||
let stored_config_path = config_file_full_path(config_file.path());
|
||||
|
||||
|
|
|
@ -80,6 +80,26 @@ pub fn default_test_config(net: Network) -> Result<ZebradConfig> {
|
|||
mining.miner_address = Some(miner_address.parse().expect("hard-coded address is valid"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "shielded_scan")]
|
||||
{
|
||||
let mut shielded_scan = zebra_scan::Config::default();
|
||||
shielded_scan.ephemeral = true;
|
||||
|
||||
let config = ZebradConfig {
|
||||
network,
|
||||
state,
|
||||
sync,
|
||||
mempool,
|
||||
consensus,
|
||||
tracing,
|
||||
mining,
|
||||
shielded_scan,
|
||||
..ZebradConfig::default()
|
||||
};
|
||||
|
||||
return Ok(config);
|
||||
}
|
||||
|
||||
let config = ZebradConfig {
|
||||
network,
|
||||
state,
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
# Default configuration for zebrad.
|
||||
#
|
||||
# This file can be used as a skeleton for custom configs.
|
||||
#
|
||||
# Unspecified fields use default values. Optional fields are Some(field) if the
|
||||
# field is present and None if it is absent.
|
||||
#
|
||||
# This file is generated as an example using zebrad's current defaults.
|
||||
# You should set only the config options you want to keep, and delete the rest.
|
||||
# Only a subset of fields are present in the skeleton, since optional values
|
||||
# whose default is None are omitted.
|
||||
#
|
||||
# The config format (including a complete list of sections and fields) is
|
||||
# documented here:
|
||||
# https://docs.rs/zebrad/latest/zebrad/config/struct.ZebradConfig.html
|
||||
#
|
||||
# zebrad attempts to load configs in the following order:
|
||||
#
|
||||
# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`;
|
||||
# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent);
|
||||
# 3. The default config.
|
||||
|
||||
[consensus]
|
||||
checkpoint_sync = true
|
||||
|
||||
[mempool]
|
||||
eviction_memory_time = "1h"
|
||||
tx_cost_limit = 80000000
|
||||
|
||||
[metrics]
|
||||
|
||||
[mining]
|
||||
debug_like_zcashd = true
|
||||
|
||||
[network]
|
||||
cache_dir = true
|
||||
crawl_new_peer_interval = "1m 1s"
|
||||
initial_mainnet_peers = [
|
||||
"dnsseed.z.cash:8233",
|
||||
"dnsseed.str4d.xyz:8233",
|
||||
"mainnet.seeder.zfnd.org:8233",
|
||||
"mainnet.is.yolo.money:8233",
|
||||
]
|
||||
initial_testnet_peers = [
|
||||
"dnsseed.testnet.z.cash:18233",
|
||||
"testnet.seeder.zfnd.org:18233",
|
||||
"testnet.is.yolo.money:18233",
|
||||
]
|
||||
listen_addr = "0.0.0.0:8233"
|
||||
max_connections_per_ip = 1
|
||||
network = "Mainnet"
|
||||
peerset_initial_target_size = 25
|
||||
|
||||
[rpc]
|
||||
debug_force_finished_sync = false
|
||||
parallel_cpu_threads = 0
|
||||
|
||||
[shielded_scan]
|
||||
cache_dir = "cache_dir"
|
||||
delete_old_database = true
|
||||
ephemeral = false
|
||||
|
||||
[shielded_scan.sapling_keys_to_scan]
|
||||
|
||||
[state]
|
||||
cache_dir = "cache_dir"
|
||||
delete_old_database = true
|
||||
ephemeral = false
|
||||
|
||||
[sync]
|
||||
checkpoint_verify_concurrency_limit = 1000
|
||||
download_concurrency_limit = 50
|
||||
full_verify_concurrency_limit = 20
|
||||
parallel_cpu_threads = 0
|
||||
|
||||
[tracing]
|
||||
buffer_limit = 128000
|
||||
force_use_color = false
|
||||
use_color = true
|
||||
use_journald = false
|
Loading…
Reference in New Issue