diff --git a/proto/service.proto b/proto/service.proto index 49f97ea..d0548df 100644 --- a/proto/service.proto +++ b/proto/service.proto @@ -20,6 +20,7 @@ message BlockID { message BlockRange { BlockID start = 1; BlockID end = 2; + uint64 spamFilterThreshold = 3; } // A TxFilter contains the information needed to identify a particular diff --git a/src/chain.rs b/src/chain.rs index 076c692..3faf043 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -152,6 +152,7 @@ pub async fn download_chain( start_height: u32, end_height: u32, mut prev_hash: Option<[u8; 32]>, + max_cost: u32, blocks_tx: Sender, cancel: &'static Mutex, ) -> anyhow::Result<()> { @@ -170,6 +171,7 @@ pub async fn download_chain( height: end_height as u64, hash: vec![], }), + spam_filter_threshold: max_cost as u64, }; *DOWNLOADED_BYTES.lock().unwrap() = 0; *TRIAL_DECRYPTIONS.lock().unwrap() = 0; @@ -201,14 +203,19 @@ pub async fn download_chain( prev_hash = Some(ph); for b in block.vtx.iter_mut() { b.actions.clear(); // don't need Orchard actions + let mut skipped = false; for co in b.outputs.iter_mut() { if co.epk.is_empty() { + skipped = true; co.epk = vec![0; 32]; } if co.ciphertext.is_empty() { co.ciphertext = vec![0; 52]; } } + if skipped { + log::info!("Output skipped {}", b.outputs.len()); + } } let block_output_count: usize = block.vtx.iter().map(|tx| tx.outputs.len()).sum(); diff --git a/src/generated/cash.z.wallet.sdk.rpc.rs b/src/generated/cash.z.wallet.sdk.rpc.rs index 10f5eb7..d200197 100644 --- a/src/generated/cash.z.wallet.sdk.rpc.rs +++ b/src/generated/cash.z.wallet.sdk.rpc.rs @@ -109,6 +109,8 @@ pub struct BlockRange { pub start: ::core::option::Option, #[prost(message, optional, tag="2")] pub end: ::core::option::Option, + #[prost(uint64, tag="3")] + pub spam_filter_threshold: u64, } /// A TxFilter contains the information needed to identify a particular /// transaction: either a block and an index, or a direct transaction hash. diff --git a/src/main/rpc.rs b/src/main/rpc.rs index 23c364a..0f2447f 100644 --- a/src/main/rpc.rs +++ b/src/main/rpc.rs @@ -11,7 +11,7 @@ use rocket::{response, Request, Response, State}; use std::collections::HashMap; use std::fs::File; use std::io::{BufReader, Read}; -use std::sync::atomic::AtomicBool; +use std::sync::Mutex; use thiserror::Error; use warp_api_ffi::api::payment::{Recipient, RecipientMemo}; use warp_api_ffi::api::payment_uri::PaymentURI; @@ -21,7 +21,7 @@ use warp_api_ffi::{ }; lazy_static! { - static ref SYNC_CANCELED: AtomicBool = AtomicBool::new(false); + static ref SYNC_CANCELED: Mutex = Mutex::new(false); } #[derive(Error, Debug)] diff --git a/src/scan.rs b/src/scan.rs index a34bc79..1f49e4d 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -94,6 +94,7 @@ pub async fn sync_async( start_height, end_height, prev_hash, + max_cost, decryptor_tx, cancel, )