pub struct TxMerkleNode(/* private fields */);Expand description
A hash of the Merkle tree branch or root for transactions.
Implementations§
§impl TxMerkleNode
impl TxMerkleNode
pub const fn from_byte_array(bytes: [u8; 32]) -> Self
pub const fn from_byte_array(bytes: [u8; 32]) -> Self
Constructs a new type from the underlying byte array.
pub const fn to_byte_array(self) -> [u8; 32]
pub const fn to_byte_array(self) -> [u8; 32]
Returns the underlying byte array.
pub const fn as_byte_array(&self) -> &[u8; 32]
pub const fn as_byte_array(&self) -> &[u8; 32]
Returns a reference to the underlying byte array.
Source§impl TxMerkleNode
impl TxMerkleNode
Sourcepub fn combine(&self, other: &Self) -> Self
pub fn combine(&self, other: &Self) -> Self
Combine two nodes to get a single node. The final node of a tree is called the “root”.
Sourcepub fn calculate_root<I: Iterator<Item = Txid>>(iter: I) -> Option<Self>
pub fn calculate_root<I: Iterator<Item = Txid>>(iter: I) -> Option<Self>
Given an iterator of leaves, compute the Merkle root.
Returns None if the iterator was empty, or if the transaction list contains
consecutive duplicates which would trigger CVE 2012-2459. Blocks with duplicate
transactions will always be invalid, so there is no harm in us refusing to
compute their merkle roots.
Unless you are certain your transaction list is nonempty and has no duplicates,
you should not unwrap the Option returned by this method!
Trait Implementations§
§impl<'a> Arbitrary<'a> for TxMerkleNode
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for TxMerkleNode
Available on crate feature
arbitrary only.§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read more§impl AsRef<[u8]> for TxMerkleNode
impl AsRef<[u8]> for TxMerkleNode
§impl AsRef<[u8; 32]> for TxMerkleNode
impl AsRef<[u8; 32]> for TxMerkleNode
§impl Borrow<[u8]> for TxMerkleNode
impl Borrow<[u8]> for TxMerkleNode
§impl Borrow<[u8; 32]> for TxMerkleNode
impl Borrow<[u8; 32]> for TxMerkleNode
Source§impl Clone for TxMerkleNode
impl Clone for TxMerkleNode
Source§fn clone(&self) -> TxMerkleNode
fn clone(&self) -> TxMerkleNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TxMerkleNode
impl Debug for TxMerkleNode
Source§impl Decodable for TxMerkleNode
impl Decodable for TxMerkleNode
§impl<'de> Deserialize<'de> for TxMerkleNode
impl<'de> Deserialize<'de> for TxMerkleNode
§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<TxMerkleNode, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<TxMerkleNode, D::Error>
Deserialize this value from the given Serde deserializer. Read more
§impl Display for TxMerkleNode
Available on crate feature hex only.
impl Display for TxMerkleNode
Available on crate feature
hex only.Source§impl Encodable for TxMerkleNode
impl Encodable for TxMerkleNode
§impl FromStr for TxMerkleNode
Available on crate feature hex only.
impl FromStr for TxMerkleNode
Available on crate feature
hex only.Source§impl Hash for TxMerkleNode
impl Hash for TxMerkleNode
§impl LowerHex for TxMerkleNode
Available on crate feature hex only.
impl LowerHex for TxMerkleNode
Available on crate feature
hex only.Source§impl Ord for TxMerkleNode
impl Ord for TxMerkleNode
Source§fn cmp(&self, other: &TxMerkleNode) -> Ordering
fn cmp(&self, other: &TxMerkleNode) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for TxMerkleNode
impl PartialEq for TxMerkleNode
Source§impl PartialOrd for TxMerkleNode
impl PartialOrd for TxMerkleNode
§impl Serialize for TxMerkleNode
impl Serialize for TxMerkleNode
§impl UpperHex for TxMerkleNode
Available on crate feature hex only.
impl UpperHex for TxMerkleNode
Available on crate feature
hex only.impl Copy for TxMerkleNode
impl Eq for TxMerkleNode
impl StructuralPartialEq for TxMerkleNode
Auto Trait Implementations§
impl Freeze for TxMerkleNode
impl RefUnwindSafe for TxMerkleNode
impl Send for TxMerkleNode
impl Sync for TxMerkleNode
impl Unpin for TxMerkleNode
impl UnsafeUnpin for TxMerkleNode
impl UnwindSafe for TxMerkleNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more