rust-bitcoin-unsafe-fast/bitcoin/src
Andrew Poelstra 44a6402875
Merge rust-bitcoin/rust-bitcoin#2740: Add difficulty adjustment calculation
47dc4a3180 feat(pow): add difficulty adjustment calculation (Rob N)

Pull request description:

  Hi, I hit a roadblock with the current `pow` API. As far as I can tell, the only workaround to calculate the next work required similar to `bitcoin/src/pow.cpp` is to use a general big integer library, convert the `Target` to bytes, do the math, and convert back to `Target` from bytes. I have also been working with [Floresta](780ea8d0b0) and their [solution](780ea8d0b0/crates/floresta-chain/src/pruned_utreexo/consensus.rs (L187)) was to fork off and exposed the `U256` struct publicly on their branch. I think these home brewed difficulty adjustment solutions will continually pop up, so I created a `from_next_work_required` method to return a `Target`. My work veers significantly from #2180, as I only provided a single method to do so, without further guidance on when exactly this retarget occurs.

  I am happy to add tests once I get further direction from maintainers if this as a likelihood of being accepted or not. Thanks.

ACKs for top commit:
  tcharding:
    ACK 47dc4a3180
  apoelstra:
    ACK 47dc4a3180 used range-diff

Tree-SHA512: 6d627ce698361afed61c8f2a12a1a96371a7a93118e08a91dae250de4f23d65c615d2654d37d2699c88b7c22f6e4bc2a1195f963c15512d7c0d041498f02dc41
2024-05-15 13:42:25 +00:00
..
address bitcoin: Stop slicing hashes 2024-04-25 12:53:58 +10:00
blockdata Improve deprecation notice 2024-04-10 11:05:05 +10:00
consensus Merge rust-bitcoin/rust-bitcoin#2699: Set release version in deprecated attribute 2024-04-23 01:45:04 +00:00
crypto Merge rust-bitcoin/rust-bitcoin#2707: Default to forward for tagged hashes 2024-05-07 14:16:16 +00:00
merkle_tree 2024-03-31 automated rustfmt nightly 2024-03-31 01:03:18 +00:00
p2p 2024-04-07 automated rustfmt nightly 2024-04-07 01:03:23 +00:00
psbt Merge rust-bitcoin/rust-bitcoin#2760: bip32: derive_xpriv should not return a Result 2024-05-13 22:35:49 +00:00
taproot Default to forward for tagged hashes 2024-04-23 12:58:14 +10:00
bip32.rs bip32: derive_xpriv should not return a Result 2024-05-13 20:43:49 +00:00
bip152.rs Merge rust-bitcoin/rust-bitcoin#2667: Remove deprecated legacy numeric methods 2024-04-07 15:15:47 +00:00
bip158.rs Implement infallible for errors 2024-03-08 16:48:34 +11:00
error.rs Do infallible int from hex conversions 2024-02-27 10:40:52 +11:00
hash_types.rs 2024-03-31 automated rustfmt nightly 2024-03-31 01:03:18 +00:00
internal_macros.rs 2024-03-31 automated rustfmt nightly 2024-03-31 01:03:18 +00:00
lib.rs Minimize usage of Network in public API 2024-04-03 13:32:39 +11:00
network.rs Minimize usage of Network in public API 2024-04-03 13:32:39 +11:00
policy.rs bitcoin: Remove attribution from all files 2023-05-01 09:22:48 +10:00
pow.rs feat(pow): add difficulty adjustment calculation 2024-05-14 16:49:53 -10:00
serde_utils.rs Fix new nightly warnings/errors 2024-02-21 14:13:49 +11:00
sign_message.rs Implement infallible for errors 2024-03-08 16:48:34 +11:00
test_macros.rs bitcoin: Remove attribution from all files 2023-05-01 09:22:48 +10:00