feat(config): Allow to add keys to be scanned by the zebra-scan crate to config (#7949)

* allow user to add sapling keys to config

* apply code review suggestions

Co-authored-by: teor <teor@riseup.net>

---------

Co-authored-by: teor <teor@riseup.net>
This commit is contained in:
Alfredo Garcia 2023-11-15 22:32:22 -03:00 committed by GitHub
parent 732ee01443
commit a22c8d5f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 0 deletions

View File

@ -5780,8 +5780,10 @@ dependencies = [
"color-eyre",
"ff",
"group",
"indexmap 2.1.0",
"jubjub",
"rand 0.8.5",
"serde",
"tokio",
"zcash_client_backend",
"zcash_note_encryption",
@ -5959,6 +5961,7 @@ dependencies = [
"zebra-network",
"zebra-node-services",
"zebra-rpc",
"zebra-scan",
"zebra-state",
"zebra-test",
"zebra-utils",

View File

@ -21,6 +21,9 @@ categories = ["cryptography::cryptocurrencies"]
[dependencies]
zebra-chain = { path = "../zebra-chain", version = "1.0.0-beta.31" }
indexmap = { version = "2.0.1", features = ["serde"] }
serde = { version = "1.0.192", features = ["serde_derive"] }
[dev-dependencies]
zcash_client_backend = "0.10.0-rc.1"

23
zebra-scan/src/config.rs Normal file
View File

@ -0,0 +1,23 @@
//! Configuration for blockchain scanning tasks.
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use crate::storage::SaplingScanningKey;
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
#[serde(deny_unknown_fields, default)]
/// Configuration for scanning.
pub struct Config {
/// The sapling keys to scan for and the birthday height of each of them.
// TODO: any value below sapling activation as the birthday height should default to sapling activation.
pub sapling_keys_to_scan: IndexMap<SaplingScanningKey, u32>,
}
impl Default for Config {
fn default() -> Self {
Self {
sapling_keys_to_scan: IndexMap::new(),
}
}
}

View File

@ -4,6 +4,7 @@
#![doc(html_logo_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-icon.png")]
#![doc(html_root_url = "https://docs.rs/zebra_scan")]
pub mod config;
mod storage;
#[cfg(test)]

View File

@ -68,6 +68,9 @@ getblocktemplate-rpcs = [
"zebra-chain/getblocktemplate-rpcs",
]
# Experimental shielded blockchain scanning
shielded-scan = ["zebra-scan"]
# Experimental elasticsearch indexing
elasticsearch = [
"zebra-state/elasticsearch",
@ -152,6 +155,9 @@ zebra-node-services = { path = "../zebra-node-services", version = "1.0.0-beta.3
zebra-rpc = { path = "../zebra-rpc", version = "1.0.0-beta.31" }
zebra-state = { path = "../zebra-state", version = "1.0.0-beta.31" }
# Experimental shielded-scan feature
zebra-scan = { path = "../zebra-scan", version = "0.1.0-alpha.0", optional = true }
# Required for crates.io publishing, but it's only used in tests
zebra-utils = { path = "../zebra-utils", version = "1.0.0-beta.31", optional = true }

View File

@ -43,4 +43,8 @@ pub struct ZebradConfig {
#[serde(skip_serializing_if = "zebra_rpc::config::mining::Config::skip_getblocktemplate")]
/// Mining configuration
pub mining: zebra_rpc::config::mining::Config,
#[cfg(feature = "zebra-scan")]
/// Scanner configuration
pub shielded_scan: zebra_scan::config::Config,
}