Skip to content

Commit 22b050c

Browse files
committed
removed getset from nullifier map and wallet block
1 parent 74b4ca1 commit 22b050c

File tree

7 files changed

+44
-23
lines changed

7 files changed

+44
-23
lines changed

zingo-sync/src/primitives.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,10 @@ impl From<OutputId> for OutPoint {
258258
}
259259

260260
/// Binary tree map of nullifiers from transaction spends or actions
261-
#[derive(Debug, Getters, MutGetters)]
262-
#[getset(get = "pub", get_mut = "pub")]
261+
#[derive(Debug)]
263262
pub struct NullifierMap {
264-
sapling: BTreeMap<sapling_crypto::Nullifier, Locator>,
265-
orchard: BTreeMap<orchard::note::Nullifier, Locator>,
263+
pub(crate) sapling: BTreeMap<sapling_crypto::Nullifier, Locator>,
264+
pub(crate) orchard: BTreeMap<orchard::note::Nullifier, Locator>,
266265
}
267266

268267
impl NullifierMap {
@@ -272,6 +271,11 @@ impl NullifierMap {
272271
orchard: BTreeMap::new(),
273272
}
274273
}
274+
275+
pub fn clear(&mut self) {
276+
self.sapling.clear();
277+
self.orchard.clear();
278+
}
275279
}
276280

277281
impl Default for NullifierMap {
@@ -281,14 +285,12 @@ impl Default for NullifierMap {
281285
}
282286

283287
/// Wallet block data
284-
#[derive(Debug, Clone, CopyGetters)]
285-
#[getset(get_copy = "pub")]
288+
#[derive(Debug, Clone)]
286289
pub struct WalletBlock {
287290
block_height: BlockHeight,
288291
block_hash: BlockHash,
289292
prev_hash: BlockHash,
290293
time: u32,
291-
#[getset(skip)]
292294
txids: Vec<TxId>,
293295
tree_boundaries: TreeBoundaries,
294296
// TODO: optional price
@@ -313,9 +315,29 @@ impl WalletBlock {
313315
}
314316
}
315317

318+
pub fn block_height(&self) -> BlockHeight {
319+
self.block_height
320+
}
321+
322+
pub fn block_hash(&self) -> BlockHash {
323+
self.block_hash
324+
}
325+
326+
pub fn prev_hash(&self) -> BlockHash {
327+
self.prev_hash
328+
}
329+
330+
pub fn time(&self) -> u32 {
331+
self.time
332+
}
333+
316334
pub fn txids(&self) -> &[TxId] {
317335
&self.txids
318336
}
337+
338+
pub fn tree_boundaries(&self) -> TreeBoundaries {
339+
self.tree_boundaries
340+
}
319341
}
320342

321343
/// Wallet transaction

zingo-sync/src/scan/compact_blocks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ fn collect_nullifiers(
396396
.map(|spend| sapling_crypto::Nullifier::from_slice(spend.nf.as_slice()).unwrap())
397397
.for_each(|nullifier| {
398398
nullifier_map
399-
.sapling_mut()
399+
.sapling
400400
.insert(nullifier, (block_height, transaction.txid()));
401401
});
402402
transaction
@@ -408,7 +408,7 @@ fn collect_nullifiers(
408408
})
409409
.for_each(|nullifier| {
410410
nullifier_map
411-
.orchard_mut()
411+
.orchard
412412
.insert(nullifier, (block_height, transaction.txid()));
413413
});
414414
Ok(())

zingo-sync/src/scan/transactions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ fn collect_nullifiers(
493493
.map(|spend| spend.nullifier())
494494
.for_each(|nullifier| {
495495
nullifier_map
496-
.sapling_mut()
496+
.sapling
497497
.insert(*nullifier, (block_height, transaction.txid()));
498498
});
499499
}
@@ -504,7 +504,7 @@ fn collect_nullifiers(
504504
.map(|action| action.nullifier())
505505
.for_each(|nullifier| {
506506
nullifier_map
507-
.orchard_mut()
507+
.orchard
508508
.insert(*nullifier, (block_height, transaction.txid()));
509509
});
510510
}

zingo-sync/src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,12 @@ where
581581
wallet
582582
.get_nullifiers_mut()
583583
.unwrap()
584-
.sapling_mut()
584+
.sapling
585585
.retain(|_, (height, _)| *height > fully_scanned_height);
586586
wallet
587587
.get_nullifiers_mut()
588588
.unwrap()
589-
.orchard_mut()
589+
.orchard
590590
.retain(|_, (height, _)| *height > fully_scanned_height);
591591
wallet
592592
.get_sync_state_mut()

zingo-sync/src/sync/spend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ pub(super) fn detect_shielded_spends(
117117
) {
118118
let sapling_spend_locators = sapling_derived_nullifiers
119119
.iter()
120-
.flat_map(|nf| nullifier_map.sapling_mut().remove_entry(nf))
120+
.flat_map(|nf| nullifier_map.sapling.remove_entry(nf))
121121
.collect();
122122
let orchard_spend_locators = orchard_derived_nullifiers
123123
.iter()
124-
.flat_map(|nf| nullifier_map.orchard_mut().remove_entry(nf))
124+
.flat_map(|nf| nullifier_map.orchard.remove_entry(nf))
125125
.collect();
126126

127127
(sapling_spend_locators, orchard_spend_locators)

zingo-sync/src/traits.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ pub trait SyncNullifiers: SyncWallet {
168168
/// Append nullifiers to wallet nullifier map
169169
fn append_nullifiers(&mut self, mut nullifiers: NullifierMap) -> Result<(), Self::Error> {
170170
self.get_nullifiers_mut()?
171-
.sapling_mut()
172-
.append(nullifiers.sapling_mut());
171+
.sapling
172+
.append(&mut nullifiers.sapling);
173173
self.get_nullifiers_mut()?
174-
.orchard_mut()
175-
.append(nullifiers.orchard_mut());
174+
.orchard
175+
.append(&mut nullifiers.orchard);
176176

177177
Ok(())
178178
}
@@ -181,10 +181,10 @@ pub trait SyncNullifiers: SyncWallet {
181181
fn truncate_nullifiers(&mut self, truncate_height: BlockHeight) -> Result<(), Self::Error> {
182182
let nullifier_map = self.get_nullifiers_mut()?;
183183
nullifier_map
184-
.sapling_mut()
184+
.sapling
185185
.retain(|_, (block_height, _)| *block_height <= truncate_height);
186186
nullifier_map
187-
.orchard_mut()
187+
.orchard
188188
.retain(|_, (block_height, _)| *block_height <= truncate_height);
189189

190190
Ok(())

zingolib/src/wallet.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,7 @@ impl LightWallet {
224224
pub fn clear_all(&mut self) {
225225
self.wallet_blocks.clear();
226226
self.wallet_transactions.clear();
227-
self.nullifier_map.sapling_mut().clear();
228-
self.nullifier_map.orchard_mut().clear();
227+
self.nullifier_map.clear();
229228
self.outpoint_map.clear();
230229
self.sync_state = SyncState::new();
231230
}

0 commit comments

Comments
 (0)