From 7a5482d23a47d7ba4eb7f5670321594cb68e010f Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Mon, 4 Apr 2022 17:59:31 +0200 Subject: [PATCH] Rename LeafInfo into ScriptLeaf --- src/util/psbt/map/output.rs | 10 +++++----- src/util/taproot.rs | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/util/psbt/map/output.rs b/src/util/psbt/map/output.rs index e32792c2..5f96559a 100644 --- a/src/util/psbt/map/output.rs +++ b/src/util/psbt/map/output.rs @@ -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 { @@ -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 { diff --git a/src/util/taproot.rs b/src/util/taproot.rs index ec8c1ca1..512d6a9f 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -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, + pub(crate) leaves: Vec, /// 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)