Skip to content

Commit

Permalink
Merge pull request #961 from fluidvanadium/add_comments
Browse files Browse the repository at this point in the history
add comments
  • Loading branch information
zancas authored Apr 23, 2024
2 parents 335978f + 91183aa commit d31c850
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
10 changes: 8 additions & 2 deletions zingolib/src/blaze/block_management_reorg_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Node<D> = <<D as DomainWalletExt>::WalletNote as ShieldedNoteInterface>::No
const ORCHARD_START: &str = "000000";
/// The data relating to the blocks in the current batch
pub struct BlockManagementData {
// List of all downloaded blocks in the current batch and
// List of all downloaded Compact Blocks in the current batch and
// their hashes/commitment trees. Stored with the tallest
// block first, and the shortest last.
blocks_in_current_batch: Arc<RwLock<Vec<BlockData>>>,
Expand Down Expand Up @@ -447,13 +447,19 @@ impl BlockManagementData {
self.wait_for_block(after_height).await;

{
// Read Lock
// Read Lock for the Block Cache
let blocks = self.blocks_in_current_batch.read().await;
// take the height of the first/highest block in the batch and subtract target height to get index into the block list
let pos = blocks.first().unwrap().height - after_height;
match nf {
PoolNullifier::Sapling(nf) => {
let nf = nf.to_vec();

// starting with a block and searching until the top of the batch
// if this block contains a transaction
// that contains a spent
// with the given nullifier
// return its height
for i in (0..pos + 1).rev() {
let cb = &blocks.get(i as usize).unwrap().cb();
for compact_transaction in &cb.vtx {
Expand Down
2 changes: 2 additions & 0 deletions zingolib/src/blaze/update_notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ impl UpdateNotes {
.await
{
//info!("Note was spent, just add it as spent for TxId {}", txid);
// we got the height the nullifier was spent at. now, we go back to the index because we need to read from that CompactTx.
// This can only happen after BlazeSyncData has been downloaded into the LightClient from the server and stored asyncronously.
let (compact_transaction, ts) = bsync_data
.read()
.await
Expand Down
5 changes: 4 additions & 1 deletion zingolib/src/wallet/transactions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//! Functionality for managing transactions
//! This mod should be called tx_map_and_maybe_trees.rs. it contains
//! struct TxMapAndMaybeTrees
//! implementations for TxMapAndMaybeTrees
//! associated types for TxMapAndMaybeTrees that have no relevance elsewhere.

use crate::wallet::{data::WitnessTrees, transaction_records_by_id::TransactionRecordsById};

Expand Down
3 changes: 3 additions & 0 deletions zingolib/src/wallet/transactions/get.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! contains associated methods for asking TxMapAndMaybeTrees about the data it contains
//! Does not contain trait implementations

use zcash_note_encryption::Domain;
use zcash_primitives::{consensus::BlockHeight, transaction::TxId};

Expand Down
2 changes: 2 additions & 0 deletions zingolib/src/wallet/transactions/read_write.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! contains associated methods for writing TxMapAndMaybeTrees to disk and reading TxMapAndMaybeTrees from disk

use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::{
collections::HashMap,
Expand Down
2 changes: 2 additions & 0 deletions zingolib/src/wallet/transactions/recording.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! contains associated methods for modifying and updating TxMapAndMaybeTrees

use incrementalmerkletree::Position;
use orchard::note_encryption::OrchardDomain;
use sapling_crypto::note_encryption::SaplingDomain;
Expand Down

0 comments on commit d31c850

Please sign in to comment.