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

Refactor inner Txs interface #3200

Open
grarco opened this issue May 8, 2024 · 3 comments
Open

Refactor inner Txs interface #3200

grarco opened this issue May 8, 2024 · 3 comments

Comments

@grarco
Copy link
Contributor

grarco commented May 8, 2024

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 #3103 (comment)

@grarco grarco added this to the Phase 1: mainnet genesis milestone May 8, 2024
@grarco grarco mentioned this issue May 8, 2024
2 tasks
@sug0
Copy link
Contributor

sug0 commented May 13, 2024

Depends on #3103

@cwgoes
Copy link
Contributor

cwgoes commented Aug 22, 2024

@grarco Is this still applicable?

@grarco
Copy link
Contributor Author

grarco commented Aug 22, 2024

Yes it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants