Skip to content

Adds possibility to make math operations on the Target type #1993

@vincenzopalazzo

Description

@vincenzopalazzo

I am upgrading nakamoto to rust-bitcoin 0.30 and before we were using Uint256 type for implementing the target.

Now that the type was hidden under the Target type I noted that there is no way to
make math operations on the target in order to calculate a new one.

In particular, our previous code is the following, (the last_target is a Uint256

       let mut target = last_target;

        target = target.mul_u32(adjusted_timespan);
        target = target / Target::from_u64(params.pow_target_timespan).unwrap();

So I think that the target should allow to make the multiplication and the division
with the Target type in order to manipulate an object.

Any thought?

This was also discuss in here #1820

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions