namada
namada copied to clipboard
Refactor inner `Tx`s interface
Possible improvement of the way we access the section commitments of an inner tx
enum TxCommitmentRef {
Id(TxCommitments),
Hash(Hash),
Index(usize),
}
impl TxCommitmentRef {
fn get_commitments(
&self,
batch: impl IntoIterator<Item = &TxCommitments>,
) -> Option<&TxCommitments> {
match self {
Self::Id(commitments) => {
// FIXME: check that `commitments` is present in `batch`?
commitments
}
Self::Hash(commitments_hash) => batch.into_iter().find_map(|commitments| {
(hash(commitments) == commitments_hash).then_some(commitments)
}),
Self::Index(index) => batch.into_iter().nth(index),
}
}
}
Originally posted by @sug0 in https://github.com/anoma/namada/pull/3103#discussion_r1589154606
Depends on #3103
@grarco Is this still applicable?
Yes it is