-
Notifications
You must be signed in to change notification settings - Fork 150
[Taproot API project] move several files and tighten up iterator API #807
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
Conversation
All this does is wrap the existing (depth, script) return value in a structure that has a pile of accessors on it. The accessors include a couple of expensive computations which are currently done manually. A later commit/PR will introduce a `SpendInfo` structure which will cache these computations and amortize much of the hashing needed to produce control blocks. But these new accessors simplify some things.
9479891
to
dd17df5
Compare
Drafting for a bit -- I need to test all feature combinations. |
We are going to move TapTree into the module (hence the name), and before we can do this we need to move the iterator.
This completes the move of all the taptree-related stuff into its own module, where it will be easier to mess around with this stuff.
Moving this separately from the rest of the TapTree stuff because I changed the Policy import to Semantic and the Error import to just crate::Error (since this is the only place that type is used in the taptree module, and I don't really like this type). So this is a move-only diff but it might not look like it, so I figured I should at least make the diff small.
The name `iter_scripts` is dumb and undiscoverable. More importantly, it's misleading -- this iterator does not yield scripts. It yields Miniscripts, which can be converted to scripts if you have ToPublicKey and are willing to pay a cost.
dd17df5
to
8e5d809
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 8e5d809 successfully ran local tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code review ACK 8e5d809.
Thanks for the helpful commit messages.
/// | ||
/// This function is potentially expensive. | ||
#[inline] | ||
pub fn compute_script(&self) -> bitcoin::ScriptBuf { self.node.encode() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea of potentially naming all functions that could be expensive with compute
prefix.
This PR mostly just moves files around, but it includes two nontrivial API changes:
iter_scripts
iterator toleaves
onTr
andTaptree
(u8, Script)
tupleIn the next PRs we will completely rewrite this iterator, and
Taptree
and these preparatory commits help to reduce the diff throughout the rest of the codebase.