@@ -15,6 +15,7 @@ use units::parse::{self, ParseIntError, PrefixedHexError, UnprefixedHexError};
15
15
16
16
use crate :: block:: { BlockHash , Header } ;
17
17
use crate :: consensus:: encode:: { self , Decodable , Encodable } ;
18
+ use crate :: internal_macros:: define_extension_trait;
18
19
use crate :: network:: Params ;
19
20
20
21
/// Implement traits and methods shared by `Target` and `Work`.
@@ -355,18 +356,17 @@ impl CompactTarget {
355
356
pub fn to_consensus ( self ) -> u32 { self . 0 }
356
357
}
357
358
358
- mod tmp {
359
- use super :: * ;
360
-
361
- impl CompactTarget {
359
+ define_extension_trait ! {
360
+ /// Extension functionality for the [`CompactTarget`] type.
361
+ pub trait CompactTargetExt impl for CompactTarget {
362
362
/// Creates a `CompactTarget` from a prefixed hex string.
363
- pub fn from_hex ( s : & str ) -> Result < Self , PrefixedHexError > {
363
+ fn from_hex( s: & str ) -> Result <CompactTarget , PrefixedHexError > {
364
364
let target = parse:: hex_u32_prefixed( s) ?;
365
365
Ok ( Self :: from_consensus( target) )
366
366
}
367
367
368
368
/// Creates a `CompactTarget` from an unprefixed hex string.
369
- pub fn from_unprefixed_hex ( s : & str ) -> Result < Self , UnprefixedHexError > {
369
+ fn from_unprefixed_hex( s: & str ) -> Result <CompactTarget , UnprefixedHexError > {
370
370
let target = parse:: hex_u32_unprefixed( s) ?;
371
371
Ok ( Self :: from_consensus( target) )
372
372
}
@@ -393,7 +393,7 @@ mod tmp {
393
393
/// # Returns
394
394
///
395
395
/// The expected [`CompactTarget`] recalculation.
396
- pub fn from_next_work_required (
396
+ fn from_next_work_required(
397
397
last: CompactTarget ,
398
398
timespan: u64 ,
399
399
params: impl AsRef <Params >,
@@ -437,7 +437,7 @@ mod tmp {
437
437
/// # Returns
438
438
///
439
439
/// The expected [`CompactTarget`] recalculation.
440
- pub fn from_header_difficulty_adjustment (
440
+ fn from_header_difficulty_adjustment(
441
441
last_epoch_boundary: Header ,
442
442
current: Header ,
443
443
params: impl AsRef <Params >,
0 commit comments