Passes &Network directly instead of converting to zp_consensus::Network where there were conversions

This commit is contained in:
Arya 2024-04-02 21:09:36 -04:00
parent ad4e7dcf8a
commit 4347a80c24
3 changed files with 5 additions and 26 deletions

View File

@ -44,7 +44,7 @@ pub fn decrypts_successfully(transaction: &Transaction, network: &Network, heigh
if let Some(bundle) = alt_tx.sapling_bundle() {
for output in bundle.shielded_outputs().iter() {
let recovery = zcash_primitives::sapling::note_encryption::try_sapling_output_recovery(
&network,
network,
alt_height,
&null_sapling_ovk,
output,

View File

@ -384,25 +384,6 @@ pub fn scan_block<K: ScanningKey>(
// TODO: Implement a check that returns early when the block height is below the Sapling
// activation height.
let network = match network {
Network::Mainnet => zcash_primitives::consensus::Network::MainNetwork,
Network::Testnet(params) => {
// # Correctness:
//
// There are differences between the `TestNetwork` parameters and those returned by
// `CRegTestParams()` in zcashd, so this function can't return `TestNetwork` unless
// Zebra is using the default public Testnet.
//
// TODO: Remove this conversion by implementing `zcash_primitives::consensus::Parameters`
// for `Network` (#8365).
assert!(
params.is_default_testnet(),
"could not convert configured testnet to zcash_primitives::consensus::Network"
);
zcash_primitives::consensus::Network::TestNetwork
}
};
let chain_metadata = ChainMetadata {
sapling_commitment_tree_size: sapling_tree_size,
// Orchard is not supported at the moment so the tree size can be 0.
@ -417,7 +398,7 @@ pub fn scan_block<K: ScanningKey>(
.collect();
zcash_client_backend::scanning::scan_block(
&network,
network,
block_to_compact(block, chain_metadata),
scanning_keys.as_slice(),
// Ignore whether notes are change from a viewer's own spends for now.

View File

@ -41,15 +41,13 @@ use zebra_scan::{storage::Storage, Config};
/// - The transaction fetched via RPC cannot be deserialized from raw bytes.
#[allow(clippy::print_stdout)]
pub fn main() {
// TODO: Implement `zcash_primitives::consensus::Parameters` for `Network` and remove this variable (#8365).
let network = zcash_primitives::consensus::Network::MainNetwork;
let zebra_network = zebra_chain::parameters::Network::Mainnet;
let storage = Storage::new(&Config::default(), &zebra_network, true);
let network = zebra_chain::parameters::Network::Mainnet;
let storage = Storage::new(&Config::default(), &network, true);
// If the first memo is empty, it doesn't get printed. But we never print empty memos anyway.
let mut prev_memo = "".to_owned();
for (key, _) in storage.sapling_keys_last_heights().iter() {
let dfvk = sapling_key_to_scan_block_keys(key, &zebra_network)
let dfvk = sapling_key_to_scan_block_keys(key, &network)
.expect("Scanning key from the storage should be valid")
.0
.into_iter()