Separate CompactTarget impl blocks
In preparation for adding an `CompactTargetExt` trait move the primitives methods to a separate impl block. Refactor only, no logic changes.
This commit is contained in:
parent
22d5646f7b
commit
578143c09e
|
@ -347,6 +347,14 @@ do_impl!(Target);
|
|||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct CompactTarget(u32);
|
||||
|
||||
impl CompactTarget {
|
||||
/// Creates a [`CompactTarget`] from a consensus encoded `u32`.
|
||||
pub fn from_consensus(bits: u32) -> Self { Self(bits) }
|
||||
|
||||
/// Returns the consensus encoded `u32` representation of this [`CompactTarget`].
|
||||
pub fn to_consensus(self) -> u32 { self.0 }
|
||||
}
|
||||
|
||||
impl CompactTarget {
|
||||
/// Creates a `CompactTarget` from a prefixed hex string.
|
||||
pub fn from_hex(s: &str) -> Result<Self, PrefixedHexError> {
|
||||
|
@ -435,12 +443,6 @@ impl CompactTarget {
|
|||
let bits = current.bits;
|
||||
CompactTarget::from_next_work_required(bits, timespan.into(), params)
|
||||
}
|
||||
|
||||
/// Creates a [`CompactTarget`] from a consensus encoded `u32`.
|
||||
pub fn from_consensus(bits: u32) -> Self { Self(bits) }
|
||||
|
||||
/// Returns the consensus encoded `u32` representation of this [`CompactTarget`].
|
||||
pub fn to_consensus(self) -> u32 { self.0 }
|
||||
}
|
||||
|
||||
impl From<CompactTarget> for Target {
|
||||
|
|
Loading…
Reference in New Issue