Skip to content

Conversation

@JoseSK999
Copy link
Contributor

What is the purpose of this pull request?

  • Bug fix
  • Documentation update
  • New feature
  • Test
  • Other: Refactor

Which crates are being modified?

  • floresta-chain
  • floresta-cli
  • floresta-common
  • floresta-compact-filters
  • floresta-electrum
  • floresta-watch-only
  • floresta-wire
  • floresta
  • florestad
  • Other:

Description

Relates to #463. A couple of replacements of unwrap for expect with proper messages.

In partial_chain.rs get_validation_flags now takes the hash directly from the caller, avoiding the unwrap (exactly as we do for get_validation_flags in chain_state.rs).

In get_leaf_hashes (udata.rs) we instead take the TxOut directly. We also avoid computing the txid twice by passing it.

Notes to the reviewers

The only remaining unwraps in floresta-chain are in chain_state.rs. We can then remove them (with a bit of error handling) and enforce they are not re-introduced.

A couple of replacements of `unwrap` for `expect` with proper messages.

In partial_chain.rs `get_validation_flags` now takes the hash directly from the caller, avoiding the `unwrap` (exactly as we do for `get_validation_flags` in chain_state.rs).

In `get_leaf_hashes` (udata.rs) we instead take the TxOut directly. We also avoid computing the txid twice by passing it.
@Davidson-Souza Davidson-Souza added documentation Improvements or additions to documentation chore Cleaning, refactoring, reducing complexity code quality Generally improves code readability and maintainability labels May 6, 2025
Copy link
Member

@Davidson-Souza Davidson-Souza left a comment

Choose a reason for hiding this comment

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

ACK d08ad21

Copy link
Contributor

@lucad70 lucad70 left a comment

Choose a reason for hiding this comment

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

At first I was concerned about the change on the get_leaf_hashes() as I thought it was being used elsewhere but as it isn't and you address its usage later on the code (at what used to be line 475), I believe it is alright.

Overall I am not a fan of using expect even while guaranteeing the impossibility of error, however, as discussed previously, this is accordingly to objectives, so, ACK d08ad21

@Davidson-Souza Davidson-Souza merged commit 89590a1 into vinteumorg:master May 7, 2025
10 checks passed
luisschwab pushed a commit to luisschwab/Floresta that referenced this pull request May 8, 2025
A couple of replacements of `unwrap` for `expect` with proper messages.

In partial_chain.rs `get_validation_flags` now takes the hash directly from the caller, avoiding the `unwrap` (exactly as we do for `get_validation_flags` in chain_state.rs).

In `get_leaf_hashes` (udata.rs) we instead take the TxOut directly. We also avoid computing the txid twice by passing it.
@JoseSK999 JoseSK999 deleted the remove-unwraps branch May 14, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Cleaning, refactoring, reducing complexity code quality Generally improves code readability and maintainability documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants