You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge rust-bitcoin#4458: locktimes: replace MtpAndHeight type with pair of BlockMtp and BlockHeight
47c77af units: delete MtpAndHeight type (Andrew Poelstra)
d82b8c0 primitives: stop using MtpAndHeight (Andrew Poelstra)
72d5fba units: stop using MtpAndHeight in locktime::relative is_satisfied_by methods (Andrew Poelstra)
d933c75 units: change type of MtpHeight::to_mtp to BlockMtp (Andrew Poelstra)
dcbdb7c units: add checked arithmetic to Block{Height,Mtp}{Interval,} (Andrew Poelstra)
4300271 units: add constructor for absolute::Mtp from timestamps (Andrew Poelstra)
4e4601b units: rename BlockInterval to BlockHeightInterval (Andrew Poelstra)
cb882c5 units: add global `BlockMtpInterval` type (Andrew Poelstra)
4e3af51 units: add global `BlockMtp` type (Andrew Poelstra)
a3228d4 units: pull u32 conversions for BlockHeight/BlockInterval into macro (Andrew Poelstra)
Pull request description:
This is a more involved PR than I'd expected but hopefully the individual commits make sense and are well-motivated. Essentially, my goal was to replace `MtpAndHeight` as used by relative locktimes with a pair of `Mtp` and `Height`.
However, relative locktimes, when given a MTP/Height for the UTXO creation and the chain tip, are roughly modeled as "take a diff of MTPs to get a `relative::MtpInterval`, a diff of heights to get a `relative::HeightInterval`, and compare to the locktimes". *However*, we have no standalone MTP type to "take a diff of", and also there are failure modes when creating the diffs (e.g. if the diff would exceed the range of `MtpInterval` or `HeightInterval`).
So I backed up and decided to use the existing `BlockHeight`/`BlockInterval` as the type to "take a diff of". I needed to introduce a `BlockMtp`/`BlockMtpInterval` to work with MTPs. These types have full-u32 range, unlike the similarly-named types in `units::locktimes::absolute`. I then needed to add some conversion methods. Along the way, I cleaned up the APIs and documentation, added checked arithmetic, etc., as needed.
See the individual commit messages for more detail.
I believe the resulting API is much more consistent and discoverable, even though it has more surface than the old API.
I considered splitting this into 2 PRs but I think the first half of the changes aren't well-motivated with out the second half. Let me know.
ACKs for top commit:
tcharding:
ACK 47c77af
Tree-SHA512: ebe19a5b1684db8c2d913274347c994026aaa0dcdd79349c237920a82fe55560777278efdbbc7f1b1424c9391d9bbd891ae844db885deea75288000437a8a287
0 commit comments