Skip to content

Followup to #895: rename dissat_sat function and use struct rather than tuple for return values#930

Open
apoelstra wants to merge 2 commits intorust-bitcoin:masterfrom
apoelstra:2026-04/followup-895
Open

Followup to #895: rename dissat_sat function and use struct rather than tuple for return values#930
apoelstra wants to merge 2 commits intorust-bitcoin:masterfrom
apoelstra:2026-04/followup-895

Conversation

@apoelstra
Copy link
Copy Markdown
Member

Makes naming more consistent and reduces confusion caused by having a tuple with two entries of the same type.

It is too easy to get the satisfactions and dissatisfactions confused. Use
a struct with named fields.

Curiously, outside of this module dissatisfactions are never used, so we can
keep the `dissat` field private. (Well, this is a bit of a sketchy thing to
say -- dissatisfactions **are** used by the Satisfaction::thresh and
thresh_mall functions, but those functions take dissats and sats as independent
Vecs they can manipulate, rather than taking a SatDissat struct.)
The name of the function no longer implies its return value (which is a
struct rather than a tuple that needs to be carefully ordered). So change
the name to be consistent with the name of the module.
@apoelstra
Copy link
Copy Markdown
Member Author

On 5097641 successfully ran local tests

Copy link
Copy Markdown
Contributor

@trevarj trevarj left a comment

Choose a reason for hiding this comment

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

Much nicer!

ACK 6c2dc1a

Comment on lines +486 to +489
let (dissats, sats): (Vec<_>, Vec<_>) = sat_dissats
.into_iter()
.map(|SatDissat { dissat, sat }| (dissat, sat))
.unzip();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

                let (dissats, sats): (Vec<_>, Vec<_>) = stack
                    .drain(stack.len() - thresh.n()..)
                    .map(|SatDissat { dissat, sat }| (dissat, sat))
                    .unzip();

}
}

/// The (dissatisfaction, satisfaction) pair for an `older` fragment.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor nit, can ignore: Find and replace on "(dissatisfaction, satisfaction) pair" to just "satisfaction and dissatisfaction" or "SatDissat" in the doc comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants