Skip to content

Commit

Permalink
Fix in preparation for next edition
Browse files Browse the repository at this point in the history
Use cargo to upgrade from edition 2015 to edition 2018.

 cargo fix --edition

No manual changes made. The result of the command above is just to fix
all the use statements (add `crate::`) and fix the fully qualified path
formats i.e., `::Foo` -> `crate::Foo`.
  • Loading branch information
tcharding committed May 11, 2022
1 parent af1f259 commit dca0d67
Show file tree
Hide file tree
Showing 42 changed files with 456 additions and 456 deletions.
38 changes: 19 additions & 19 deletions src/blockdata/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
//! these blocks and the blockchain.
//!
use prelude::*;
use crate::prelude::*;

use core::fmt;

use util;
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
use util::hash::bitcoin_merkle_root;
use hashes::{Hash, HashEngine};
use hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
use util::uint::Uint256;
use consensus::encode::Encodable;
use network::constants::Network;
use blockdata::transaction::Transaction;
use blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
use blockdata::script;
use VarInt;
use crate::util;
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
use crate::util::hash::bitcoin_merkle_root;
use crate::hashes::{Hash, HashEngine};
use crate::hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
use crate::util::uint::Uint256;
use crate::consensus::encode::Encodable;
use crate::network::constants::Network;
use crate::blockdata::transaction::Transaction;
use crate::blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
use crate::blockdata::script;
use crate::VarInt;

/// A block header, which contains all the block's information except
/// the actual transactions
Expand Down Expand Up @@ -359,13 +359,13 @@ impl ::std::error::Error for Bip34Error {}

#[cfg(test)]
mod tests {
use hashes::hex::FromHex;
use crate::hashes::hex::FromHex;

use blockdata::block::{Block, BlockHeader};
use consensus::encode::{deserialize, serialize};
use util::uint::Uint256;
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
use network::constants::Network;
use crate::blockdata::block::{Block, BlockHeader};
use crate::consensus::encode::{deserialize, serialize};
use crate::util::uint::Uint256;
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
use crate::network::constants::Network;

#[test]
fn test_coinbase_and_bip34() {
Expand Down
30 changes: 15 additions & 15 deletions src/blockdata/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
//! single transaction.
//!
use prelude::*;
use crate::prelude::*;

use core::default::Default;

use hashes::hex::{self, HexIterator};
use hashes::sha256d;
use blockdata::opcodes;
use blockdata::script;
use blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
use blockdata::block::{Block, BlockHeader};
use blockdata::witness::Witness;
use network::constants::Network;
use util::uint::Uint256;
use crate::hashes::hex::{self, HexIterator};
use crate::hashes::sha256d;
use crate::blockdata::opcodes;
use crate::blockdata::script;
use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
use crate::blockdata::block::{Block, BlockHeader};
use crate::blockdata::witness::Witness;
use crate::network::constants::Network;
use crate::util::uint::Uint256;

/// The maximum allowable sequence number
pub const MAX_SEQUENCE: u32 = 0xFFFFFFFF;
Expand Down Expand Up @@ -179,12 +179,12 @@ pub fn genesis_block(network: Network) -> Block {
#[cfg(test)]
mod test {
use core::default::Default;
use hashes::hex::FromHex;
use crate::hashes::hex::FromHex;

use network::constants::Network;
use consensus::encode::serialize;
use blockdata::constants::{genesis_block, bitcoin_genesis_tx};
use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
use crate::network::constants::Network;
use crate::consensus::encode::serialize;
use crate::blockdata::constants::{genesis_block, bitcoin_genesis_tx};
use crate::blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};

#[test]
fn bitcoin_genesis_first_transaction() {
Expand Down
44 changes: 22 additions & 22 deletions src/blockdata/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
//! This module provides the structures and functions needed to support scripts.
//!
use prelude::*;
use crate::prelude::*;

use io;
use crate::io;
use core::{fmt, default::Default};
use core::ops::Index;

#[cfg(feature = "serde")] use serde;

use hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
use blockdata::opcodes;
use consensus::{encode, Decodable, Encodable};
use hashes::{Hash, hex};
use policy::DUST_RELAY_TX_FEE;
use crate::hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
use crate::blockdata::opcodes;
use crate::consensus::{encode, Decodable, Encodable};
use crate::hashes::{Hash, hex};
use crate::policy::DUST_RELAY_TX_FEE;
#[cfg(feature="bitcoinconsensus")] use bitcoinconsensus;
#[cfg(feature="bitcoinconsensus")] use core::convert::From;
use OutPoint;
use crate::OutPoint;

use util::key::PublicKey;
use util::address::WitnessVersion;
use util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
use crate::util::key::PublicKey;
use crate::util::address::WitnessVersion;
use crate::util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
use schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
use crate::schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};

/// A Bitcoin script.
#[derive(Clone, Default, PartialOrd, Ord, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -557,7 +557,7 @@ impl Script {

/// Checks whether a script can be proven to have no satisfying input.
pub fn is_provably_unspendable(&self) -> bool {
use blockdata::opcodes::Class::{ReturnOp, IllegalOp};
use crate::blockdata::opcodes::Class::{ReturnOp, IllegalOp};

match self.0.first() {
Some(b) => {
Expand All @@ -572,7 +572,7 @@ impl Script {

/// Returns the minimum value an output with this script should have in order to be
/// broadcastable on today's Bitcoin network.
pub fn dust_value(&self) -> ::Amount {
pub fn dust_value(&self) -> crate::Amount {
// This must never be lower than Bitcoin Core's GetDustThreshold() (as of v0.21) as it may
// otherwise allow users to create transactions which likely can never be broadcast/confirmed.
let sats = DUST_RELAY_TX_FEE as u64 / 1000 * // The default dust relay fee is 3000 satoshi/kB (i.e. 3 sat/vByte)
Expand All @@ -588,7 +588,7 @@ impl Script {
self.consensus_encode(&mut sink()).expect("sinks don't error") as u64 // The serialized size of this script_pubkey
};

::Amount::from_sat(sats)
crate::Amount::from_sat(sats)
}

/// Iterates over the script in the form of `Instruction`s, which are an enum covering opcodes,
Expand Down Expand Up @@ -1075,11 +1075,11 @@ mod test {
use super::*;
use super::build_scriptint;

use hashes::hex::{FromHex, ToHex};
use consensus::encode::{deserialize, serialize};
use blockdata::opcodes;
use util::key::PublicKey;
use util::psbt::serialize::Serialize;
use crate::hashes::hex::{FromHex, ToHex};
use crate::consensus::encode::{deserialize, serialize};
use crate::blockdata::opcodes;
use crate::util::key::PublicKey;
use crate::util::psbt::serialize::Serialize;

#[test]
fn script() {
Expand Down Expand Up @@ -1449,7 +1449,7 @@ mod test {
// well-known scriptPubKey types.
let script_p2wpkh = Builder::new().push_int(0).push_slice(&[42; 20]).into_script();
assert!(script_p2wpkh.is_v0_p2wpkh());
assert_eq!(script_p2wpkh.dust_value(), ::Amount::from_sat(294));
assert_eq!(script_p2wpkh.dust_value(), crate::Amount::from_sat(294));

let script_p2pkh = Builder::new()
.push_opcode(opcodes::all::OP_DUP)
Expand All @@ -1459,7 +1459,7 @@ mod test {
.push_opcode(opcodes::all::OP_CHECKSIG)
.into_script();
assert!(script_p2pkh.is_p2pkh());
assert_eq!(script_p2pkh.dust_value(), ::Amount::from_sat(546));
assert_eq!(script_p2pkh.dust_value(), crate::Amount::from_sat(546));
}

#[test]
Expand Down
44 changes: 22 additions & 22 deletions src/blockdata/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
//! This module provides the structures and functions needed to support transactions.
//!
use prelude::*;
use crate::prelude::*;

use io;
use crate::io;
use core::{fmt, str, default::Default};
#[cfg(feature = "std")] use std::error;

use hashes::{self, Hash, sha256d};
use hashes::hex::FromHex;
use crate::hashes::{self, Hash, sha256d};
use crate::hashes::hex::FromHex;

use util::endian;
use blockdata::constants::WITNESS_SCALE_FACTOR;
use crate::util::endian;
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
#[cfg(feature="bitcoinconsensus")] use blockdata::script;
use blockdata::script::Script;
use blockdata::witness::Witness;
use consensus::{encode, Decodable, Encodable};
use consensus::encode::MAX_VEC_SIZE;
use hash_types::{Sighash, Txid, Wtxid};
use VarInt;
use crate::blockdata::script::Script;
use crate::blockdata::witness::Witness;
use crate::consensus::{encode, Decodable, Encodable};
use crate::consensus::encode::MAX_VEC_SIZE;
use crate::hash_types::{Sighash, Txid, Wtxid};
use crate::VarInt;

#[cfg(doc)]
use util::sighash::SchnorrSighashType;
Expand Down Expand Up @@ -895,17 +895,17 @@ mod tests {
use super::*;

use core::str::FromStr;
use blockdata::constants::WITNESS_SCALE_FACTOR;
use blockdata::script::Script;
use consensus::encode::serialize;
use consensus::encode::deserialize;
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
use crate::blockdata::script::Script;
use crate::consensus::encode::serialize;
use crate::consensus::encode::deserialize;

use hashes::Hash;
use hashes::hex::FromHex;
use crate::hashes::Hash;
use crate::hashes::hex::FromHex;

use hash_types::*;
use crate::hash_types::*;
use super::EcdsaSighashType;
use util::sighash::SighashCache;
use crate::util::sighash::SighashCache;

#[test]
fn test_outpoint() {
Expand Down Expand Up @@ -958,8 +958,8 @@ mod tests {

#[test]
fn test_is_coinbase () {
use network::constants::Network;
use blockdata::constants;
use crate::network::constants::Network;
use crate::blockdata::constants;

let genesis = constants::genesis_block(Network::Bitcoin);
assert! (genesis.txdata[0].is_coin_base());
Expand Down
24 changes: 12 additions & 12 deletions src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
//! This module contains the [`Witness`] struct and related methods to operate on it
//!
use blockdata::transaction::EcdsaSighashType;
use consensus::encode::{Error, MAX_VEC_SIZE};
use consensus::{Decodable, Encodable, WriteExt};
use io::{self, Read, Write};
use prelude::*;
use crate::blockdata::transaction::EcdsaSighashType;
use crate::consensus::encode::{Error, MAX_VEC_SIZE};
use crate::consensus::{Decodable, Encodable, WriteExt};
use crate::io::{self, Read, Write};
use crate::prelude::*;
use secp256k1::ecdsa;
use VarInt;
use crate::VarInt;

#[cfg(feature = "serde")]
use serde;
Expand Down Expand Up @@ -302,12 +302,12 @@ impl<'de> serde::Deserialize<'de> for Witness {

#[cfg(test)]
mod test {
use blockdata::transaction::EcdsaSighashType;
use blockdata::witness::Witness;
use consensus::{deserialize, serialize};
use hashes::hex::{FromHex, ToHex};
use Transaction;
use secp256k1::ecdsa;
use super::*;

use crate::consensus::{deserialize, serialize};
use crate::hashes::hex::{FromHex, ToHex};
use crate::Transaction;
use crate::secp256k1::ecdsa;

#[test]
fn test_push() {
Expand Down
26 changes: 13 additions & 13 deletions src/consensus/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@
//! typically big-endian decimals, etc.)
//!
use prelude::*;
use crate::prelude::*;

use core::{fmt, mem, u32, convert::From};
#[cfg(feature = "std")] use std::error;

use hashes::{sha256d, Hash, sha256};
use hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader};
use crate::hashes::{sha256d, Hash, sha256};
use crate::hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader};

use io::{self, Cursor, Read};
use crate::io::{self, Cursor, Read};

use util::endian;
use util::psbt;
use util::taproot::TapLeafHash;
use hashes::hex::ToHex;
use crate::util::endian;
use crate::util::psbt;
use crate::util::taproot::TapLeafHash;
use crate::hashes::hex::ToHex;

use blockdata::transaction::{TxOut, Transaction, TxIn};
use crate::blockdata::transaction::{TxOut, Transaction, TxIn};
#[cfg(feature = "std")]
use network::{message_blockdata::Inventory, address::{Address, AddrV2Message}};
use crate::network::{message_blockdata::Inventory, address::{Address, AddrV2Message}};

/// Encoding error
#[derive(Debug)]
Expand Down Expand Up @@ -776,11 +776,11 @@ mod tests {
use core::{mem::{self, discriminant}, fmt};
use super::{deserialize, serialize, Error, CheckedData, VarInt};
use super::{Transaction, BlockHash, FilterHash, TxMerkleNode, TxOut, TxIn};
use consensus::{Encodable, deserialize_partial, Decodable};
use util::endian::{u64_to_array_le, u32_to_array_le, u16_to_array_le};
use crate::consensus::{Encodable, deserialize_partial, Decodable};
use crate::util::endian::{u64_to_array_le, u32_to_array_le, u16_to_array_le};
use secp256k1::rand::{thread_rng, Rng};
#[cfg(feature = "std")]
use network::{Address, message_blockdata::Inventory};
use crate::network::{Address, message_blockdata::Inventory};

#[test]
fn serialize_int_test() {
Expand Down
4 changes: 2 additions & 2 deletions src/consensus/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
//! chains (such as mainnet, testnet).
//!
use network::constants::Network;
use util::uint::Uint256;
use crate::network::constants::Network;
use crate::util::uint::Uint256;

/// Lowest possible difficulty for Mainnet. See comment on Params::pow_limit for more info.
const MAX_BITS_BITCOIN: Uint256 = Uint256([
Expand Down
2 changes: 1 addition & 1 deletion src/hash_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! hash).
//!
use hashes::{Hash, sha256, sha256d, hash160};
use crate::hashes::{Hash, sha256, sha256d, hash160};

macro_rules! impl_hashencode {
($hashtype:ident) => {
Expand Down
Loading

0 comments on commit dca0d67

Please sign in to comment.