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 transaction building combinators #3057

Merged
merged 6 commits into from
Nov 1, 2019

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Sep 25, 2019

This allows for more robust error handling as we can now propagate errors up to the top level.

Specifically the Append type which takes a Result and returns a Result.

pub type Append<K, B> = dyn for<'a> Fn(
	&'a mut Context<'_, K, B>,
	Result<(Transaction, TxKernel, BlindSum), Error>,
) -> Result<(Transaction, TxKernel, BlindSum), Error>;

Also replaced with_fee() and with_lock_height() combinators with simply passing in kernel features to build::transaction() and build::partial_transaction(). It was confusing (and fragile) setting fee and lock_height individually via combinators. We now explicitly specify the features for the kernel of the tx being built.

let tx = transaction(
    KernelFeatures::Plain { fee: 4 },
    vec![
        input(6, key_id1),
        output(2, key_id2),
    ],
    &keychain,
    &builder,
)

NOTE: Wallet uses build::transaction() and build::partial_transaction() so we need to be careful merging this to make sure the wallet project is updated to reflect this.

@antiochp antiochp changed the title [DNM] tx combinators now take operate on Result [DNM] transaction building combinators now operate on Result Sep 25, 2019
@antiochp antiochp force-pushed the tx_combinator_refactor branch from 7900c31 to f083762 Compare September 25, 2019 16:23
@antiochp antiochp changed the title [DNM] transaction building combinators now operate on Result [DNM] Refactor transaction building combinators Sep 25, 2019
@antiochp antiochp added this to the 3.0.0 milestone Sep 30, 2019
@antiochp antiochp changed the title [DNM] Refactor transaction building combinators Refactor transaction building combinators Oct 4, 2019
@antiochp antiochp force-pushed the tx_combinator_refactor branch from 6dfb655 to a78bc68 Compare October 30, 2019 10:11
@lehnberg lehnberg modified the milestones: tentative 3.0.0, 3.0.0 Oct 30, 2019
@lehnberg lehnberg added the P3: Fix if time Nice to have, does not block release label Oct 30, 2019
Copy link
Member

@yeastplume yeastplume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I've always thought the combinators were unnecessarily confusing, so it's a welcome refactor.

@antiochp
Copy link
Member Author

antiochp commented Nov 1, 2019

Merging this. grin-wallet will no longer build until the related PR is also merged.

@antiochp antiochp merged commit 50ce7ba into mimblewimble:master Nov 1, 2019
@antiochp antiochp deleted the tx_combinator_refactor branch November 1, 2019 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement P3: Fix if time Nice to have, does not block release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants