Struct bitcoin::pow::CompactTarget
source · pub struct CompactTarget(/* private fields */);
Expand description
Encoding of 256-bit target as 32-bit float.
This is used to encode a target into the block header. Satoshi made this part of consensus code in the original version of Bitcoin, likely copying an idea from OpenSSL.
OpenSSL’s bignum (BN) type has an encoding, which is even called “compact” as in bitcoin, which is exactly this format.
Implementations§
source§impl CompactTarget
impl CompactTarget
sourcepub fn from_consensus(bits: u32) -> Self
pub fn from_consensus(bits: u32) -> Self
Creates a CompactTarget
from a consensus encoded u32
.
sourcepub fn to_consensus(self) -> u32
pub fn to_consensus(self) -> u32
Returns the consensus encoded u32
representation of this CompactTarget
.
Trait Implementations§
source§impl Clone for CompactTarget
impl Clone for CompactTarget
source§fn clone(&self) -> CompactTarget
fn clone(&self) -> CompactTarget
Returns a copy 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 CompactTarget
impl Debug for CompactTarget
source§impl Decodable for CompactTarget
impl Decodable for CompactTarget
source§impl Default for CompactTarget
impl Default for CompactTarget
source§fn default() -> CompactTarget
fn default() -> CompactTarget
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for CompactTarget
impl<'de> Deserialize<'de> for CompactTarget
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Encodable for CompactTarget
impl Encodable for CompactTarget
source§impl From<CompactTarget> for Target
impl From<CompactTarget> for Target
source§fn from(c: CompactTarget) -> Self
fn from(c: CompactTarget) -> Self
Converts to this type from the input type.
source§impl FromHexStr for CompactTarget
impl FromHexStr for CompactTarget
source§impl Hash for CompactTarget
impl Hash for CompactTarget
source§impl Ord for CompactTarget
impl Ord for CompactTarget
source§fn cmp(&self, other: &CompactTarget) -> Ordering
fn cmp(&self, other: &CompactTarget) -> 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<CompactTarget> for CompactTarget
impl PartialEq<CompactTarget> for CompactTarget
source§fn eq(&self, other: &CompactTarget) -> bool
fn eq(&self, other: &CompactTarget) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<CompactTarget> for CompactTarget
impl PartialOrd<CompactTarget> for CompactTarget
source§fn partial_cmp(&self, other: &CompactTarget) -> Option<Ordering>
fn partial_cmp(&self, other: &CompactTarget) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for CompactTarget
impl Serialize for CompactTarget
impl Copy for CompactTarget
impl Eq for CompactTarget
impl StructuralEq for CompactTarget
impl StructuralPartialEq for CompactTarget
Auto Trait Implementations§
impl RefUnwindSafe for CompactTarget
impl Send for CompactTarget
impl Sync for CompactTarget
impl Unpin for CompactTarget
impl UnwindSafe for CompactTarget
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