diff --git a/zingolib/CHANGELOG.md b/zingolib/CHANGELOG.md index a499a625c..a2ea4dc08 100644 --- a/zingolib/CHANGELOG.md +++ b/zingolib/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Removed + +- `lightclient.bsync_data.uri()` + +## [mobile-release-1.4.3-0-g9fa99407] + ### Deprecated - `lightclient::LightClient::do_list_transactions` diff --git a/zingolib/src/blaze/block_management_reorg_detection.rs b/zingolib/src/blaze/block_management_reorg_detection.rs index 3b2a32138..51e3be3d9 100644 --- a/zingolib/src/blaze/block_management_reorg_detection.rs +++ b/zingolib/src/blaze/block_management_reorg_detection.rs @@ -505,7 +505,7 @@ impl BlockManagementData { /// currently of the opinion that this function should be factored into separate concerns. pub(crate) async fn get_note_witness( &self, - uri: Uri, + lightwalletd_uri: Uri, height: BlockHeight, transaction_num: usize, output_num: usize, @@ -521,7 +521,8 @@ impl BlockManagementData { let tree = if prev_height < activation_height { frontier::CommitmentTree::<::Node, 32>::empty() } else { - let tree_state = crate::grpc_connector::get_trees(uri, prev_height).await?; + let tree_state = + crate::grpc_connector::get_trees(lightwalletd_uri, prev_height).await?; let tree = hex::decode(D::get_tree(&tree_state)).unwrap(); self.unverified_treestates.write().await.push(tree_state); read_commitment_tree(&tree[..]).map_err(|e| format!("{}", e))? diff --git a/zingolib/src/blaze/syncdata.rs b/zingolib/src/blaze/syncdata.rs index 4b55c8036..1d2ef9992 100644 --- a/zingolib/src/blaze/syncdata.rs +++ b/zingolib/src/blaze/syncdata.rs @@ -1,35 +1,27 @@ use std::sync::Arc; -use http::Uri; use tokio::sync::RwLock; use zcash_client_backend::proto::service::TreeState; use super::{block_management_reorg_detection::BlockManagementData, sync_status::BatchSyncStatus}; -use crate::config::ZingoConfig; use crate::wallet::data::BlockData; use crate::wallet::WalletOptions; pub struct BlazeSyncData { pub(crate) block_data: BlockManagementData, - uri: Arc>, pub(crate) wallet_options: WalletOptions, } impl BlazeSyncData { - pub fn new(config: &ZingoConfig) -> Self { + pub fn new() -> Self { let sync_status = Arc::new(RwLock::new(BatchSyncStatus::default())); Self { - uri: config.lightwalletd_uri.clone(), block_data: BlockManagementData::new(sync_status), wallet_options: WalletOptions::default(), } } - pub fn uri(&self) -> Uri { - self.uri.read().unwrap().clone() - } - pub async fn setup_nth_batch( &mut self, start_block: u64, diff --git a/zingolib/src/blaze/trial_decryptions.rs b/zingolib/src/blaze/trial_decryptions.rs index cee4cc556..fa9cfeac2 100644 --- a/zingolib/src/blaze/trial_decryptions.rs +++ b/zingolib/src/blaze/trial_decryptions.rs @@ -301,6 +301,7 @@ impl TrialDecryptions { .collect::>(); let maybe_decrypted_outputs = zcash_note_encryption::batch::try_compact_note_decryption(&[ivk], &outputs); + for maybe_decrypted_output in maybe_decrypted_outputs.into_iter().enumerate() { let (output_num, witnessed) = if let (i, Some(((note, to), _ivk_num))) = maybe_decrypted_output { @@ -321,7 +322,6 @@ impl TrialDecryptions { //TODO: Wrong. We don't have fvk import, all our keys are spending let have_spending_key = true; - let uri = bsync_data.read().await.uri().clone(); // Get the witness for the note let witness = bsync_data @@ -329,7 +329,7 @@ impl TrialDecryptions { .await .block_data .get_note_witness::( - uri, + config.get_lightwalletd_uri(), height, transaction_num, i, diff --git a/zingolib/src/lightclient.rs b/zingolib/src/lightclient.rs index 6748995dd..cf050fbf3 100644 --- a/zingolib/src/lightclient.rs +++ b/zingolib/src/lightclient.rs @@ -217,7 +217,7 @@ pub struct UserBalances { pub incoming_dust: u64, } -/// The LightClient provides a unified interface to the separate concerns that the zingolib library manages. +/// The LightClient connects one LightWallet to one lightwalletd server via gRPC. /// 1. initialization of stored state /// * from seed /// * from keys @@ -226,6 +226,8 @@ pub struct UserBalances { /// 2. synchronization of the client with the state of the blockchain via a gRPC server /// * pub struct LightClient { + // / the LightClient connects to one server. + // pub(crate) server_uri: Arc>, pub(crate) config: ZingoConfig, /// TODO: Add Doc Comment Here! pub wallet: LightWallet, @@ -242,7 +244,7 @@ pub struct LightClient { save_buffer: ZingoSaveBuffer, } -/// This is the omnibus interface to the library, we are currently in the process of refining this typez broad definition! +/// all the wonderfully intertwined ways to conjure a LightClient pub mod instantiation { use log::debug; use std::{ @@ -275,7 +277,7 @@ pub mod instantiation { config: config.clone(), mempool_monitor: std::sync::RwLock::new(None), sync_lock: Mutex::new(()), - bsync_data: Arc::new(RwLock::new(BlazeSyncData::new(&config))), + bsync_data: Arc::new(RwLock::new(BlazeSyncData::new())), interrupt_sync: Arc::new(RwLock::new(false)), latest_proposal: Arc::new(RwLock::new(None)), save_buffer: ZingoSaveBuffer::new(buffer), diff --git a/zingolib/src/wallet/disk.rs b/zingolib/src/wallet/disk.rs index 68b4a3c0c..79389520d 100644 --- a/zingolib/src/wallet/disk.rs +++ b/zingolib/src/wallet/disk.rs @@ -197,8 +197,16 @@ impl LightWallet { WalletZecPriceInfo::read(&mut reader)? }; + // this initialization combines two types of data let transaction_context = TransactionContext::new( + // Config data could be used differently based on the circumstances + // hardcoded? + // entered at init by user? + // stored on disk in a separate location and connected by a descendant library (such as zingo-mobile)? config, + // Saveable Arc data + // - Arcs allow access between threads. + // - This data is loaded from the wallet file and but needs multithreaded access during sync. Arc::new(wallet_capability), Arc::new(RwLock::new(transactions)), );