Rename LeafInfo into ScriptLeaf
This commit is contained in:
parent
2b8d96581a
commit
7a5482d23a
|
@ -26,7 +26,7 @@ use util::psbt::map::Map;
|
|||
use util::psbt::raw;
|
||||
use util::psbt::Error;
|
||||
|
||||
use util::taproot::{LeafInfo, TapLeafHash};
|
||||
use util::taproot::{ScriptLeaf, TapLeafHash};
|
||||
|
||||
use util::taproot::{NodeInfo, TaprootBuilder};
|
||||
|
||||
|
@ -156,7 +156,7 @@ impl TapTree {
|
|||
}
|
||||
|
||||
/// Returns [`TapTreeIter`] iterator for a taproot script tree, operating in DFS order over
|
||||
/// leaf depth and leaf script pairs.
|
||||
/// tree [`ScriptLeaf`]s.
|
||||
pub fn script_leaves(&self) -> TapTreeIter {
|
||||
self.into_iter()
|
||||
}
|
||||
|
@ -165,11 +165,11 @@ impl TapTree {
|
|||
/// Iterator for a taproot script tree, operating in DFS order over leaf depth and
|
||||
/// leaf script pairs.
|
||||
pub struct TapTreeIter<'tree> {
|
||||
leaf_iter: core::slice::Iter<'tree, LeafInfo>,
|
||||
leaf_iter: core::slice::Iter<'tree, ScriptLeaf>,
|
||||
}
|
||||
|
||||
impl<'tree> Iterator for TapTreeIter<'tree> {
|
||||
type Item = &'tree LeafInfo;
|
||||
type Item = &'tree ScriptLeaf;
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
@ -178,7 +178,7 @@ impl<'tree> Iterator for TapTreeIter<'tree> {
|
|||
}
|
||||
|
||||
impl<'tree> IntoIterator for &'tree TapTree {
|
||||
type Item = &'tree LeafInfo;
|
||||
type Item = &'tree ScriptLeaf;
|
||||
type IntoIter = TapTreeIter<'tree>;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
|
|
|
@ -560,7 +560,7 @@ pub struct NodeInfo {
|
|||
/// Merkle hash for this node.
|
||||
pub(crate) hash: sha256::Hash,
|
||||
/// Information about leaves inside this node.
|
||||
pub(crate) leaves: Vec<LeafInfo>,
|
||||
pub(crate) leaves: Vec<ScriptLeaf>,
|
||||
/// Tracks information on hidden nodes below this node.
|
||||
pub(crate) has_hidden_nodes: bool,
|
||||
}
|
||||
|
@ -577,7 +577,7 @@ impl NodeInfo {
|
|||
|
||||
/// Creates a new leaf [`NodeInfo`] with given [`Script`] and [`LeafVersion`].
|
||||
pub fn new_leaf_with_ver(script: Script, ver: LeafVersion) -> Self {
|
||||
let leaf = LeafInfo::new(script, ver);
|
||||
let leaf = ScriptLeaf::new(script, ver);
|
||||
Self {
|
||||
hash: sha256::Hash::from_inner(leaf.leaf_hash().into_inner()),
|
||||
leaves: vec![leaf],
|
||||
|
@ -608,7 +608,7 @@ impl NodeInfo {
|
|||
/// Store information about taproot leaf node.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct LeafInfo {
|
||||
pub struct ScriptLeaf {
|
||||
/// The underlying script.
|
||||
script: Script,
|
||||
/// The leaf version.
|
||||
|
@ -617,8 +617,8 @@ pub struct LeafInfo {
|
|||
merkle_branch: TaprootMerkleBranch,
|
||||
}
|
||||
|
||||
impl LeafInfo {
|
||||
/// Creates an new [`LeafInfo`] from `script` and `ver` and no merkle branch.
|
||||
impl ScriptLeaf {
|
||||
/// Creates an new [`ScriptLeaf`] from `script` and `ver` and no merkle branch.
|
||||
fn new(script: Script, ver: LeafVersion) -> Self {
|
||||
Self {
|
||||
script: script,
|
||||
|
@ -635,7 +635,7 @@ impl LeafInfo {
|
|||
self.merkle_branch.0.len() as u8
|
||||
}
|
||||
|
||||
/// Computes a leaf hash for this [`LeafInfo`].
|
||||
/// Computes a leaf hash for this [`ScriptLeaf`].
|
||||
#[inline]
|
||||
pub fn leaf_hash(&self) -> TapLeafHash {
|
||||
TapLeafHash::from_script(&self.script, self.ver)
|
||||
|
|
Loading…
Reference in New Issue