Skip to content

Commit 74b4ca1

Browse files
committed
removed getset from output index and changed to u16
1 parent 690ce69 commit 74b4ca1

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

zingo-sync/src/scan/compact_blocks.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ fn calculate_sapling_leaves_and_retentions<D: Domain>(
294294
last_outputs_in_block: bool,
295295
incoming_decrypted_outputs: &HashMap<OutputId, DecryptedOutput<D, ()>>,
296296
) -> Result<Vec<(Node, Retention<BlockHeight>)>, ()> {
297-
let incoming_output_indices: Vec<usize> = incoming_decrypted_outputs
297+
let incoming_output_indexes = incoming_decrypted_outputs
298298
.keys()
299299
.copied()
300300
.map(|output_id| output_id.output_index())
301-
.collect();
301+
.collect::<Vec<_>>();
302302

303303
if outputs.is_empty() {
304304
Ok(Vec::new())
@@ -314,7 +314,7 @@ fn calculate_sapling_leaves_and_retentions<D: Domain>(
314314

315315
let last_output_in_block: bool =
316316
last_outputs_in_block && output_index == last_output_index;
317-
let decrypted: bool = incoming_output_indices.contains(&output_index);
317+
let decrypted: bool = incoming_output_indexes.contains(&(output_index as u16));
318318
let retention = match (decrypted, last_output_in_block) {
319319
(is_marked, true) => Retention::Checkpoint {
320320
id: block_height,
@@ -342,11 +342,11 @@ fn calculate_orchard_leaves_and_retentions<D: Domain>(
342342
last_outputs_in_block: bool,
343343
incoming_decrypted_outputs: &HashMap<OutputId, DecryptedOutput<D, ()>>,
344344
) -> Result<Vec<(MerkleHashOrchard, Retention<BlockHeight>)>, ()> {
345-
let incoming_output_indices: Vec<usize> = incoming_decrypted_outputs
345+
let incoming_output_indexes = incoming_decrypted_outputs
346346
.keys()
347347
.copied()
348348
.map(|output_id| output_id.output_index())
349-
.collect();
349+
.collect::<Vec<_>>();
350350

351351
if actions.is_empty() {
352352
Ok(Vec::new())
@@ -362,7 +362,7 @@ fn calculate_orchard_leaves_and_retentions<D: Domain>(
362362

363363
let last_output_in_block: bool =
364364
last_outputs_in_block && output_index == last_output_index;
365-
let decrypted: bool = incoming_output_indices.contains(&output_index);
365+
let decrypted: bool = incoming_output_indexes.contains(&(output_index as u16));
366366
let retention = match (decrypted, last_output_in_block) {
367367
(is_marked, true) => Retention::Checkpoint {
368368
id: block_height,

zingo-sync/src/scan/transactions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn scan_incoming_coins<P: consensus::Parameters>(
323323
if let Some(address) = output.recipient_address() {
324324
let encoded_address = keys::transparent::encode_address(consensus_parameters, address);
325325
if let Some((address, key_id)) = transparent_addresses.get_key_value(&encoded_address) {
326-
let output_id = OutputId::from_parts(txid, output_index);
326+
let output_id = OutputId::from_parts(txid, output_index as u16);
327327

328328
transparent_coins.push(TransparentCoin::from_parts(
329329
output_id,
@@ -358,7 +358,7 @@ where
358358
.enumerate()
359359
{
360360
if let Some(((note, _, memo_bytes), key_index)) = output {
361-
let output_id = OutputId::from_parts(txid, output_index);
361+
let output_id = OutputId::from_parts(txid, output_index as u16);
362362
let (nullifier, position) = nullifiers_and_positions.map_or((None, None), |m| {
363363
m.get(&output_id)
364364
.map(|(nf, pos)| (Some(*nf), Some(*pos)))
@@ -401,7 +401,7 @@ where
401401
&output.out_ciphertext(),
402402
) {
403403
outgoing_notes.push(OutgoingNote::from_parts(
404-
OutputId::from_parts(txid, output_index),
404+
OutputId::from_parts(txid, output_index as u16),
405405
key_ids[key_index],
406406
note,
407407
Memo::from_bytes(memo_bytes.as_ref()).unwrap(),

zingolib/src/wallet/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ pub mod summaries {
17711771
/// Not to be used for internal logic in the system.
17721772
#[derive(Clone, PartialEq, Debug)]
17731773
pub struct OutgoingNoteSummary {
1774-
pub output_index: usize,
1774+
pub output_index: u16,
17751775
pub key_id: KeyId,
17761776
pub value: u64,
17771777
pub memo: Option<String>,

zingolib/src/wallet/zcb_traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,12 @@ impl InputSource for LightWallet {
515515
let exclude_sapling = exclude
516516
.iter()
517517
.filter(|&note_id| note_id.protocol() == ShieldedProtocol::Sapling)
518-
.map(|note_id| OutputId::from_parts(*note_id.txid(), note_id.output_index() as usize))
518+
.map(|note_id| OutputId::from_parts(*note_id.txid(), note_id.output_index()))
519519
.collect::<Vec<_>>();
520520
let exclude_orchard = exclude
521521
.iter()
522522
.filter(|&note_id| note_id.protocol() == ShieldedProtocol::Orchard)
523-
.map(|note_id| OutputId::from_parts(*note_id.txid(), note_id.output_index() as usize))
523+
.map(|note_id| OutputId::from_parts(*note_id.txid(), note_id.output_index()))
524524
.collect::<Vec<_>>();
525525
let mut remaining_value_needed = RemainingNeeded::Positive(target_value);
526526

0 commit comments

Comments
 (0)