Struct 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_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 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 more§impl Debug for CompactTarget
impl Debug for CompactTarget
§impl Decodable for CompactTarget
impl Decodable for CompactTarget
§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 FromHexStr for CompactTarget
impl FromHexStr for CompactTarget
§type Error = ParseIntError
type Error = ParseIntError
An error occurred while parsing the hex string.
§fn from_hex_str_no_prefix<S>(
s: S,
) -> Result<CompactTarget, <CompactTarget as FromHexStr>::Error>
fn from_hex_str_no_prefix<S>( s: S, ) -> Result<CompactTarget, <CompactTarget as FromHexStr>::Error>
Parses provided string as hex without requiring 0x prefix. Read more
§fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>
fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>
Parses provided string as hex requiring 0x prefix. Read more
§impl Hash for CompactTarget
impl Hash for CompactTarget
§impl Ord for CompactTarget
impl Ord for CompactTarget
§impl PartialEq for CompactTarget
impl PartialEq for CompactTarget
§impl PartialOrd for CompactTarget
impl PartialOrd for CompactTarget
§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 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§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Forward to the method defined on the type
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Forward to the method defined on the type
Any
.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§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
§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
Compare self to
key
and return true
if they are equal.§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
§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request