Merge rust-bitcoin/rust-bitcoin#1172: Re-export blockdata modules

6095a4de9b Use blockdata exports (Tobin C. Harding)
4a119e5624 Re-export blockdata modules (Tobin C. Harding)

Pull request description:

  In an effort to make the library more ergonomic to use re-export modules from `blockdata` at the crate root level. This helps to decouple the internal code layout with the public API.

ACKs for top commit:
  apoelstra:
    ACK 6095a4de9b
  sanket1729:
    ACK 6095a4de9b

Tree-SHA512: d9e0af1fa237bf9ad730c40088fe951dbc97df5ef9407a7038c6dbeb2f7450b93b082a40d76f5c5559731ac530fd9849405afae090de9a565e312ac4951cc0d6
This commit is contained in:
sanket1729 2022-08-19 12:48:11 -07:00
commit 042235940f
No known key found for this signature in database
GPG Key ID: 648FFB183E0870A2
6 changed files with 12 additions and 13 deletions

View File

@ -81,7 +81,7 @@ impl BlockHeader {
/// [`Uint256`]: ../../util/uint/struct.Uint256.html /// [`Uint256`]: ../../util/uint/struct.Uint256.html
/// ///
/// ``` /// ```
/// use bitcoin::blockdata::block::BlockHeader; /// use bitcoin::block::BlockHeader;
/// ///
/// assert_eq!(0x1d00ffff, /// assert_eq!(0x1d00ffff,
/// BlockHeader::compact_target_from_u256( /// BlockHeader::compact_target_from_u256(

View File

@ -283,7 +283,7 @@ impl LockTime {
/// ///
/// # Examples /// # Examples
/// ```no_run /// ```no_run
/// # use bitcoin::blockdata::locktime::{LockTime, Height, Time}; /// # use bitcoin::locktime::{LockTime, Height, Time};
/// // Can be implemented if block chain data is available. /// // Can be implemented if block chain data is available.
/// fn get_height() -> Height { todo!("return the current block height") } /// fn get_height() -> Height { todo!("return the current block height") }
/// fn get_time() -> Time { todo!("return the current block time") } /// fn get_time() -> Time { todo!("return the current block time") }
@ -410,7 +410,7 @@ impl Height {
/// ///
/// # Examples /// # Examples
/// ```rust /// ```rust
/// use bitcoin::blockdata::locktime::Height; /// use bitcoin::locktime::Height;
/// ///
/// let h: u32 = 741521; /// let h: u32 = 741521;
/// let height = Height::from_consensus(h).expect("invalid height value"); /// let height = Height::from_consensus(h).expect("invalid height value");
@ -493,7 +493,7 @@ impl Time {
/// ///
/// # Examples /// # Examples
/// ```rust /// ```rust
/// use bitcoin::blockdata::locktime::Time; /// use bitcoin::locktime::Time;
/// ///
/// let t: u32 = 1653195600; // May 22nd, 5am UTC. /// let t: u32 = 1653195600; // May 22nd, 5am UTC.
/// let time = Time::from_consensus(t).expect("invalid time value"); /// let time = Time::from_consensus(t).expect("invalid time value");

View File

@ -72,7 +72,7 @@ impl OutPoint {
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
/// use bitcoin::blockdata::constants::genesis_block; /// use bitcoin::constants::genesis_block;
/// use bitcoin::network::constants::Network; /// use bitcoin::network::constants::Network;
/// ///
/// let block = genesis_block(Network::Bitcoin); /// let block = genesis_block(Network::Bitcoin);

View File

@ -94,13 +94,14 @@ use std::io;
use core2::io; use core2::io;
pub use crate::address::{Address, AddressType}; pub use crate::address::{Address, AddressType};
pub use crate::blockdata::block::{Block, BlockHeader}; pub use crate::blockdata::block::{self, Block, BlockHeader};
pub use crate::blockdata::locktime::{self, LockTime, PackedLockTime}; pub use crate::blockdata::locktime::{self, LockTime, PackedLockTime};
pub use crate::blockdata::script::Script; pub use crate::blockdata::script::{self, Script};
#[allow(deprecated)] #[allow(deprecated)]
pub use crate::blockdata::transaction::SigHashType; pub use crate::blockdata::transaction::SigHashType;
pub use crate::blockdata::transaction::{OutPoint, Sequence, Transaction, TxIn, TxOut}; pub use crate::blockdata::transaction::{self, OutPoint, Sequence, Transaction, TxIn, TxOut};
pub use crate::blockdata::witness::Witness; pub use crate::blockdata::witness::{self, Witness};
pub use crate::blockdata::{constants, opcodes};
pub use crate::consensus::encode::VarInt; pub use crate::consensus::encode::VarInt;
pub use crate::hash_types::*; pub use crate::hash_types::*;
pub use crate::network::constants::Network; pub use crate::network::constants::Network;

View File

@ -78,8 +78,8 @@ impl<R: DerefMut<Target = Transaction>> SigHashCache<R> {
/// panics if `input_index` is out of bounds with respect of the number of inputs /// panics if `input_index` is out of bounds with respect of the number of inputs
/// ///
/// ``` /// ```
/// use bitcoin::util::bip143::SigHashCache;
/// use bitcoin::{EcdsaSighashType, Script, Transaction, PackedLockTime}; /// use bitcoin::{EcdsaSighashType, Script, Transaction, PackedLockTime};
/// use bitcoin::util::bip143::SigHashCache;
/// ///
/// let mut tx_to_sign = Transaction { version: 2, lock_time: PackedLockTime::ZERO, input: Vec::new(), output: Vec::new() }; /// let mut tx_to_sign = Transaction { version: 2, lock_time: PackedLockTime::ZERO, input: Vec::new(), output: Vec::new() };
/// let input_count = tx_to_sign.input.len(); /// let input_count = tx_to_sign.input.len();

View File

@ -1035,9 +1035,7 @@ impl<R: DerefMut<Target=Transaction>> SighashCache<R> {
/// ///
/// This allows in-line signing such as /// This allows in-line signing such as
/// ``` /// ```
/// use bitcoin::blockdata::transaction::Transaction; /// use bitcoin::{EcdsaSighashType, PackedLockTime, Script, SighashCache, Transaction};
/// use bitcoin::util::sighash::{EcdsaSighashType, SighashCache};
/// use bitcoin::{PackedLockTime, Script};
/// ///
/// let mut tx_to_sign = Transaction { version: 2, lock_time: PackedLockTime::ZERO, input: Vec::new(), output: Vec::new() }; /// let mut tx_to_sign = Transaction { version: 2, lock_time: PackedLockTime::ZERO, input: Vec::new(), output: Vec::new() };
/// let input_count = tx_to_sign.input.len(); /// let input_count = tx_to_sign.input.len();