Skip to content

consensus_encoding: remove Transitioning state#5130

Merged
apoelstra merged 1 commit intorust-bitcoin:masterfrom
nyonson:drop-extra-state
Oct 14, 2025
Merged

consensus_encoding: remove Transitioning state#5130
apoelstra merged 1 commit intorust-bitcoin:masterfrom
nyonson:drop-extra-state

Conversation

@nyonson
Copy link
Copy Markdown
Contributor

@nyonson nyonson commented Oct 13, 2025

Inspired by cleanup in #5129, simplify the Decoder2State by dropping the unnecessary Transitioning variant. We can just use the Errored variant and not change the state of the Decoder2 if the first decoder fails while transitioning to the second.

@github-actions github-actions bot added the C-consensus_encoding PRs modifying the consensus-encoding crate label Oct 13, 2025
// remains in an Errored state.
match mem::replace(&mut self.state, Decoder2State::Errored) {
Decoder2State::First(first, second) => {
let first_result = first.end().map_err(Err::from)?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In eb77b0d:

This map_err shouldn't be necessary.

}
E::UnexpectedEof { required, received: 0 } => {
write!(f, "required at least {} bytes but the input is empty", required)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In eb77b0d:

Is this a format-only change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, yes, I just ran the fmt on the crate out of habit and missed this change.

Simplify the Decoder2State by dropping the unnecessary Transitioning
variant. We can just use the Errored variant and not change the state
of the Decoder2 if the first decoder fails while transitioning to the
second.
@nyonson
Copy link
Copy Markdown
Contributor Author

nyonson commented Oct 13, 2025

144adfc: dropped unnecessary map_err and format fix.

Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 144adfc; successfully ran local tests

Copy link
Copy Markdown
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 144adfc

@apoelstra apoelstra merged commit 6d64b70 into rust-bitcoin:master Oct 14, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-consensus_encoding PRs modifying the consensus-encoding crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants