Skip to content

Commit d56834d

Browse files
committed
Merge rust-bitcoin#4686: Move locktime and sequence to units
029d5c6 units: Add Errors section to rustdocs (Tobin C. Harding) fa0c968 Move locktime and sequence code to units (Tobin C. Harding) d20e586 Introduce error modules to locktime (Tobin C. Harding) fe62307 Move non-pub import into correct place (Tobin C. Harding) 33ac206 Move locktimes to module directories (Tobin C. Harding) 5f3d3a5 Remove Transaction links from sequence docs (Tobin C. Harding) 19e54ee Remove links to TxIn from locktime docs (Tobin C. Harding) 48961dd Remove Transaction links from locktime docs (Tobin C. Harding) Pull request description: In hindsight `units` is a better place for locktimes. `relative` locktime needs `Sequence`. Move all that over to `units`. - Patch 1-5 are preparatory cleanup - Patch 6 creates public `error` modules as discussed and implemented for `amount` in rust-bitcoin#4683 - Patch 7 does the actual move - Patch 8 does docs fixes because we lint harder in `units` than `primitives` Close: rust-bitcoin#4678 ACKs for top commit: apoelstra: ACK 029d5c6; successfully ran local tests Tree-SHA512: b66786524c9df5b1f048cec6a337016d64e09bc4579f68d2ba4d2e989f9977feac36e2dbc38a725542b9051194379471a1374a60c962c6781f5aa73b4f61861a
2 parents 682394b + 029d5c6 commit d56834d

File tree

15 files changed

+1309
-1265
lines changed

15 files changed

+1309
-1265
lines changed

bitcoin/src/blockdata/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pub mod locktime {
3939

4040
pub use crate::consensus::encode::{self, Decodable, Encodable};
4141

42-
/// Re-export everything from the `primitives::locktime::absolute` module.
42+
/// Re-export everything from the `units::locktime::absolute` module.
4343
#[rustfmt::skip] // Keep public re-exports separate.
44-
pub use primitives::locktime::absolute::{ConversionError, Height, LockTime, ParseHeightError, ParseTimeError, MedianTimePast};
44+
pub use units::locktime::absolute::{ConversionError, Height, LockTime, ParseHeightError, ParseTimeError, MedianTimePast};
4545

4646
#[deprecated(since = "TBD", note = "use `MedianTimePast` instead")]
4747
#[doc(hidden)]
@@ -69,8 +69,8 @@ pub mod locktime {
6969
//! There are two types of lock time: lock-by-height and lock-by-time, distinguished by
7070
//! whether bit 22 of the `u32` consensus value is set.
7171
72-
/// Re-export everything from the `primitives::locktime::relative` module.
73-
pub use primitives::locktime::relative::{
72+
/// Re-export everything from the `units::locktime::relative` module.
73+
pub use units::locktime::relative::{
7474
DisabledLockTimeError, InvalidHeightError, InvalidTimeError, LockTime,
7575
NumberOf512Seconds, NumberOfBlocks, TimeOverflowError,
7676
};

primitives/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ pub mod _export {
3838
}
3939

4040
pub mod block;
41-
pub mod locktime;
4241
pub mod merkle_tree;
4342
mod opcodes;
4443
pub mod pow;
4544
#[cfg(feature = "alloc")]
4645
pub mod script;
47-
pub mod sequence;
4846
pub mod transaction;
4947
#[cfg(feature = "alloc")]
5048
pub mod witness;
@@ -54,6 +52,8 @@ pub use units::{
5452
amount::{self, Amount, SignedAmount},
5553
block::{BlockHeight, BlockHeightInterval, BlockMtp, BlockMtpInterval},
5654
fee_rate::{self, FeeRate},
55+
locktime::{self, absolute, relative},
56+
sequence::{self, Sequence},
5757
time::{self, BlockTime},
5858
weight::{self, Weight},
5959
};
@@ -75,10 +75,8 @@ pub use self::{
7575
#[doc(inline)]
7676
pub use self::{
7777
block::{BlockHash, Header as BlockHeader, Version as BlockVersion, WitnessCommitment},
78-
locktime::{absolute, relative},
7978
merkle_tree::{TxMerkleNode, WitnessMerkleNode},
8079
pow::CompactTarget,
81-
sequence::Sequence,
8280
transaction::{OutPoint, Txid, Version as TransactionVersion, Wtxid},
8381
};
8482

primitives/src/locktime/mod.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

primitives/src/transaction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ use hashes::sha256d;
2424
use internals::compact_size;
2525
#[cfg(feature = "hex")]
2626
use internals::write_err;
27+
#[cfg(feature = "alloc")]
28+
use units::locktime::absolute;
2729
#[cfg(feature = "hex")]
2830
use units::parse;
2931
#[cfg(feature = "alloc")]
32+
use units::sequence::Sequence;
33+
#[cfg(feature = "alloc")]
3034
use units::{Amount, Weight};
3135

32-
#[cfg(feature = "alloc")]
33-
use crate::locktime::absolute;
3436
#[cfg(feature = "alloc")]
3537
use crate::prelude::Vec;
3638
#[cfg(feature = "alloc")]
3739
use crate::script::ScriptBuf;
3840
#[cfg(feature = "alloc")]
39-
use crate::sequence::Sequence;
40-
#[cfg(feature = "alloc")]
4141
use crate::witness::Witness;
4242

4343
/// Bitcoin transaction.

primitives/tests/api.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ struct Default {
163163
#[derive(Debug, Clone, PartialEq, Eq)] // All public types implement Debug (C-DEBUG).
164164
struct Errors {
165165
a: transaction::ParseOutPointError,
166-
b: relative::DisabledLockTimeError,
167-
c: relative::IsSatisfiedByError,
168-
d: relative::IsSatisfiedByHeightError,
169-
e: relative::IsSatisfiedByTimeError,
166+
b: relative::error::DisabledLockTimeError,
167+
c: relative::error::IsSatisfiedByError,
168+
d: relative::error::IsSatisfiedByHeightError,
169+
e: relative::error::IsSatisfiedByTimeError,
170170
f: script::RedeemScriptSizeError,
171171
g: script::WitnessScriptSizeError,
172172
}
@@ -209,9 +209,10 @@ fn api_can_use_types_from_crate_root() {
209209

210210
#[test]
211211
fn api_can_use_all_types_from_module_locktime() {
212-
use bitcoin_primitives::locktime::relative::{
213-
DisabledLockTimeError, InvalidHeightError, InvalidTimeError, LockTime,
212+
use bitcoin_primitives::locktime::relative::error::{
213+
DisabledLockTimeError, InvalidHeightError, InvalidTimeError,
214214
};
215+
use bitcoin_primitives::locktime::relative::LockTime;
215216
use bitcoin_primitives::locktime::{absolute, relative};
216217
}
217218

units/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ alloc = ["internals/alloc","serde?/alloc"]
2020
[dependencies]
2121
internals = { package = "bitcoin-internals", path = "../internals", version = "0.4.0" }
2222

23-
serde = { version = "1.0.103", default-features = false, optional = true }
23+
serde = { version = "1.0.103", default-features = false, features = ["derive"], optional = true }
2424
arbitrary = { version = "1.4", optional = true }
2525

2626
[dev-dependencies]

units/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub mod fee;
5151
pub mod fee_rate;
5252
pub mod locktime;
5353
pub mod parse;
54+
pub mod sequence;
5455
pub mod time;
5556
pub mod weight;
5657

@@ -60,7 +61,9 @@ pub use self::{
6061
amount::{Amount, SignedAmount},
6162
block::{BlockHeight, BlockHeightInterval, BlockMtp, BlockMtpInterval},
6263
fee_rate::FeeRate,
64+
locktime::{absolute, relative},
6365
result::{NumOpError, NumOpResult, MathOp},
66+
sequence::Sequence,
6467
time::BlockTime,
6568
weight::Weight
6669
};

0 commit comments

Comments
 (0)