Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify indexes in new_ordered_outputs #2510

Merged
merged 2 commits into from
Jul 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions zebra-chain/src/transparent/utxo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Unspent transparent output data structures and functions.

use std::collections::HashMap;
use std::{collections::HashMap, convert::TryInto};

use crate::{
block::{self, Block},
Expand Down Expand Up @@ -102,10 +102,17 @@ pub fn new_ordered_outputs(
.enumerate()
{
let from_coinbase = transaction.is_coinbase();
for (index, output) in transaction.outputs().iter().cloned().enumerate() {
let index = index as u32;
for (output_index_in_transaction, output) in
transaction.outputs().iter().cloned().enumerate()
{
let output_index_in_transaction = output_index_in_transaction
.try_into()
.expect("unexpectedly large number of outputs");
new_ordered_outputs.insert(
transparent::OutPoint { hash, index },
transparent::OutPoint {
hash,
index: output_index_in_transaction,
},
OrderedUtxo::new(output, height, from_coinbase, tx_index_in_block),
);
}
Expand Down