Skip to content

Add height to tap tree #588

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

Merged
merged 4 commits into from
Aug 8, 2023
Merged

Conversation

tcharding
Copy link
Member

I stumbled across a todo in the code last week and thought I'd hack it up.

  • Patch 1: Do identifier style fix
  • Patch 2: Add a unit test to verify change in patch 3 is correct
  • Patch 3: Remove recursive call to tap_tree_height

From commit log of patch 3

Convert tuple `TapTree` tuple to a struct and add `height` to it. This
saves recusive call in `tap_tree_height` function.

While we are at it rename private function `TapTree::tap_tree_height` to
`TapTree::height` because it stutters.

@apoelstra
Copy link
Member

In 37fea86 you rename two methods -- we should add a deprecated version under the old name. (One gets renamed again in the last commit :) we only need to keep the original name.).

Otherwise c960798 looks good, I think. I'm a little uncomfortable adding a public field which can be constructed in an incorrect way, but I think it's okay for now. In general I'd like to go through this library and make things non-constructable, but that's a much bigger change and I don't have a timeline for it.

@tcharding
Copy link
Member Author

Re deprecation, can do. Re renaming twice, sorry about that :) I'll put a bit more effort in and re-spin.

This is a private function on the `TapTree` struct, we can make the name
more terse with no loss of meaning.
We use `TapTree` therefore the all lowercase version should be
`tap_tree` not `taptree`.
Use the descriptor string currently in the unit tests and add a basic
test of `tap_tree_height`.

Done in preparation for adding a height field to the tap tree.
Currently calculating the height of a `TapTree::Tree` uses a recursive
call, we can optimize this out by storing the height along with the tree
nodes.

Convert the `TapTree::Tree` tuple struct to a struct with named fields.
Include a `height` field in the new struct.
@tcharding
Copy link
Member Author

Changes in force push:

  • Put the private function rename in a separate patch at the front.
  • Left taptree() in as deprecated.
  • Re-wrote commit logs using more correct wording.

Copy link
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 476e358

Copy link
Member

@sanket1729 sanket1729 left a comment

Choose a reason for hiding this comment

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

ACK 476e358

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.

3 participants