Remove Default impl for Target and Work
A zero default value for `Target` and `Work` has no significance and/or usecase, remove the derived `Default` implementation. Includes making `Target::ZERO` public.
This commit is contained in:
parent
cb9893c4a9
commit
02a2b43b2b
|
@ -513,7 +513,7 @@ mod tests {
|
|||
assert_eq!(some_header.validate_pow(some_header.target()).unwrap(), some_header.block_hash());
|
||||
|
||||
// test with zero target
|
||||
match some_header.validate_pow(Target::default()) {
|
||||
match some_header.validate_pow(Target::ZERO) {
|
||||
Err(BlockBadTarget) => (),
|
||||
_ => panic!("unexpected result from validate_pow"),
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ macro_rules! do_impl {
|
|||
/// Work is a measure of how difficult it is to find a hash below a given [`Target`].
|
||||
///
|
||||
/// ref: <https://en.bitcoin.it/wiki/Work>
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||
pub struct Work(U256);
|
||||
|
@ -130,14 +130,14 @@ impl Sub for Work {
|
|||
/// a block. (See also [`Work`].)
|
||||
///
|
||||
/// ref: <https://en.bitcoin.it/wiki/Target>
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||
pub struct Target(U256);
|
||||
|
||||
impl Target {
|
||||
// When parsing nBits, Bitcoin Core converts a negative target threshold into a target of zero.
|
||||
const ZERO: Target = Target(U256::ZERO);
|
||||
/// When parsing nBits, Bitcoin Core converts a negative target threshold into a target of zero.
|
||||
pub const ZERO: Target = Target(U256::ZERO);
|
||||
/// The maximum possible target.
|
||||
///
|
||||
/// This value is used to calculate difficulty, which is defined as how difficult the current
|
||||
|
|
Loading…
Reference in New Issue