Struct bdk_chain::bitcoin::CompactTarget
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§
§impl CompactTarget
impl CompactTarget
pub fn from_hex(s: &str) -> Result<CompactTarget, PrefixedHexError>
pub fn from_hex(s: &str) -> Result<CompactTarget, PrefixedHexError>
Creates a CompactTarget
from an prefixed hex string.
pub fn from_unprefixed_hex(s: &str) -> Result<CompactTarget, UnprefixedHexError>
pub fn from_unprefixed_hex(s: &str) -> Result<CompactTarget, UnprefixedHexError>
Creates a CompactTarget
from an unprefixed hex string.
pub fn from_consensus(bits: u32) -> CompactTarget
pub fn from_consensus(bits: u32) -> CompactTarget
Creates a CompactTarget
from a consensus encoded u32
.
pub fn to_consensus(self) -> u32
pub fn to_consensus(self) -> u32
Returns the consensus encoded u32
representation of this CompactTarget
.
Trait Implementations§
§impl Clone for CompactTarget
impl Clone for CompactTarget
§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 more§impl Debug for CompactTarget
impl Debug for CompactTarget
§impl Decodable for CompactTarget
impl Decodable for CompactTarget
§fn consensus_decode<R>(r: &mut R) -> Result<CompactTarget, Error>
fn consensus_decode<R>(r: &mut R) -> Result<CompactTarget, Error>
Decode an object with a well-defined format. Read more
§impl Default for CompactTarget
impl Default for CompactTarget
§fn default() -> CompactTarget
fn default() -> CompactTarget
Returns the “default value” for a type. Read more
§impl<'de> Deserialize<'de> for CompactTarget
impl<'de> Deserialize<'de> for CompactTarget
§fn deserialize<__D>(
__deserializer: __D
) -> Result<CompactTarget, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<CompactTarget, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Encodable for CompactTarget
impl Encodable for CompactTarget
§impl From<CompactTarget> for Target
impl From<CompactTarget> for Target
§fn from(c: CompactTarget) -> Target
fn from(c: CompactTarget) -> Target
Converts to this type from the input type.
§impl Hash for CompactTarget
impl Hash for CompactTarget
§impl LowerHex for CompactTarget
impl LowerHex for CompactTarget
§impl Ord for CompactTarget
impl Ord for CompactTarget
§impl PartialEq for CompactTarget
impl PartialEq for CompactTarget
§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 ==
.§impl PartialOrd for CompactTarget
impl PartialOrd for CompactTarget
§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 more§impl Serialize for CompactTarget
impl Serialize for CompactTarget
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
§impl UpperHex for CompactTarget
impl UpperHex for CompactTarget
impl Copy for CompactTarget
impl Eq for CompactTarget
impl StructuralPartialEq for CompactTarget
Auto Trait Implementations§
impl Freeze for CompactTarget
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more