Skip to content

Commit 20690c3

Browse files
committed
Fix in preparation for next edition
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`.
1 parent 779f601 commit 20690c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+456
-456
lines changed

src/blockdata/block.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
//! these blocks and the blockchain.
2121
//!
2222
23-
use prelude::*;
23+
use crate::prelude::*;
2424

2525
use core::fmt;
2626

27-
use util;
28-
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
29-
use util::hash::bitcoin_merkle_root;
30-
use hashes::{Hash, HashEngine};
31-
use hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
32-
use util::uint::Uint256;
33-
use consensus::encode::Encodable;
34-
use network::constants::Network;
35-
use blockdata::transaction::Transaction;
36-
use blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
37-
use blockdata::script;
38-
use VarInt;
27+
use crate::util;
28+
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
29+
use crate::util::hash::bitcoin_merkle_root;
30+
use crate::hashes::{Hash, HashEngine};
31+
use crate::hash_types::{Wtxid, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment};
32+
use crate::util::uint::Uint256;
33+
use crate::consensus::encode::Encodable;
34+
use crate::network::constants::Network;
35+
use crate::blockdata::transaction::Transaction;
36+
use crate::blockdata::constants::{max_target, WITNESS_SCALE_FACTOR};
37+
use crate::blockdata::script;
38+
use crate::VarInt;
3939

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

360360
#[cfg(test)]
361361
mod tests {
362-
use hashes::hex::FromHex;
362+
use crate::hashes::hex::FromHex;
363363

364-
use blockdata::block::{Block, BlockHeader};
365-
use consensus::encode::{deserialize, serialize};
366-
use util::uint::Uint256;
367-
use util::Error::{BlockBadTarget, BlockBadProofOfWork};
368-
use network::constants::Network;
364+
use crate::blockdata::block::{Block, BlockHeader};
365+
use crate::consensus::encode::{deserialize, serialize};
366+
use crate::util::uint::Uint256;
367+
use crate::util::Error::{BlockBadTarget, BlockBadProofOfWork};
368+
use crate::network::constants::Network;
369369

370370
#[test]
371371
fn test_coinbase_and_bip34() {

src/blockdata/constants.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@
1919
//! single transaction.
2020
//!
2121
22-
use prelude::*;
22+
use crate::prelude::*;
2323

2424
use core::default::Default;
2525

26-
use hashes::hex::{self, HexIterator};
27-
use hashes::sha256d;
28-
use blockdata::opcodes;
29-
use blockdata::script;
30-
use blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
31-
use blockdata::block::{Block, BlockHeader};
32-
use blockdata::witness::Witness;
33-
use network::constants::Network;
34-
use util::uint::Uint256;
26+
use crate::hashes::hex::{self, HexIterator};
27+
use crate::hashes::sha256d;
28+
use crate::blockdata::opcodes;
29+
use crate::blockdata::script;
30+
use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
31+
use crate::blockdata::block::{Block, BlockHeader};
32+
use crate::blockdata::witness::Witness;
33+
use crate::network::constants::Network;
34+
use crate::util::uint::Uint256;
3535

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

184-
use network::constants::Network;
185-
use consensus::encode::serialize;
186-
use blockdata::constants::{genesis_block, bitcoin_genesis_tx};
187-
use blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
184+
use crate::network::constants::Network;
185+
use crate::consensus::encode::serialize;
186+
use crate::blockdata::constants::{genesis_block, bitcoin_genesis_tx};
187+
use crate::blockdata::constants::{MAX_SEQUENCE, COIN_VALUE};
188188

189189
#[test]
190190
fn bitcoin_genesis_first_transaction() {

src/blockdata/script.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@
2323
//! This module provides the structures and functions needed to support scripts.
2424
//!
2525
26-
use prelude::*;
26+
use crate::prelude::*;
2727

28-
use io;
28+
use crate::io;
2929
use core::{fmt, default::Default};
3030
use core::ops::Index;
3131

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

34-
use hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
35-
use blockdata::opcodes;
36-
use consensus::{encode, Decodable, Encodable};
37-
use hashes::{Hash, hex};
38-
use policy::DUST_RELAY_TX_FEE;
34+
use crate::hash_types::{PubkeyHash, WPubkeyHash, ScriptHash, WScriptHash};
35+
use crate::blockdata::opcodes;
36+
use crate::consensus::{encode, Decodable, Encodable};
37+
use crate::hashes::{Hash, hex};
38+
use crate::policy::DUST_RELAY_TX_FEE;
3939
#[cfg(feature="bitcoinconsensus")] use bitcoinconsensus;
4040
#[cfg(feature="bitcoinconsensus")] use core::convert::From;
41-
use OutPoint;
41+
use crate::OutPoint;
4242

43-
use util::key::PublicKey;
44-
use util::address::WitnessVersion;
45-
use util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
43+
use crate::util::key::PublicKey;
44+
use crate::util::address::WitnessVersion;
45+
use crate::util::taproot::{LeafVersion, TapBranchHash, TapLeafHash};
4646
use secp256k1::{Secp256k1, Verification, XOnlyPublicKey};
47-
use schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
47+
use crate::schnorr::{TapTweak, TweakedPublicKey, UntweakedPublicKey};
4848

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

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

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

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

591-
::Amount::from_sat(sats)
591+
crate::Amount::from_sat(sats)
592592
}
593593

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

1078-
use hashes::hex::{FromHex, ToHex};
1079-
use consensus::encode::{deserialize, serialize};
1080-
use blockdata::opcodes;
1081-
use util::key::PublicKey;
1082-
use util::psbt::serialize::Serialize;
1078+
use crate::hashes::hex::{FromHex, ToHex};
1079+
use crate::consensus::encode::{deserialize, serialize};
1080+
use crate::blockdata::opcodes;
1081+
use crate::util::key::PublicKey;
1082+
use crate::util::psbt::serialize::Serialize;
10831083

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

14541454
let script_p2pkh = Builder::new()
14551455
.push_opcode(opcodes::all::OP_DUP)
@@ -1459,7 +1459,7 @@ mod test {
14591459
.push_opcode(opcodes::all::OP_CHECKSIG)
14601460
.into_script();
14611461
assert!(script_p2pkh.is_p2pkh());
1462-
assert_eq!(script_p2pkh.dust_value(), ::Amount::from_sat(546));
1462+
assert_eq!(script_p2pkh.dust_value(), crate::Amount::from_sat(546));
14631463
}
14641464

14651465
#[test]

src/blockdata/transaction.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@
2323
//! This module provides the structures and functions needed to support transactions.
2424
//!
2525
26-
use prelude::*;
26+
use crate::prelude::*;
2727

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

32-
use hashes::{self, Hash, sha256d};
33-
use hashes::hex::FromHex;
32+
use crate::hashes::{self, Hash, sha256d};
33+
use crate::hashes::hex::FromHex;
3434

35-
use util::endian;
36-
use blockdata::constants::WITNESS_SCALE_FACTOR;
35+
use crate::util::endian;
36+
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
3737
#[cfg(feature="bitcoinconsensus")] use blockdata::script;
38-
use blockdata::script::Script;
39-
use blockdata::witness::Witness;
40-
use consensus::{encode, Decodable, Encodable};
41-
use consensus::encode::MAX_VEC_SIZE;
42-
use hash_types::{Sighash, Txid, Wtxid};
43-
use VarInt;
38+
use crate::blockdata::script::Script;
39+
use crate::blockdata::witness::Witness;
40+
use crate::consensus::{encode, Decodable, Encodable};
41+
use crate::consensus::encode::MAX_VEC_SIZE;
42+
use crate::hash_types::{Sighash, Txid, Wtxid};
43+
use crate::VarInt;
4444

4545
#[cfg(doc)]
4646
use util::sighash::SchnorrSighashType;
@@ -895,17 +895,17 @@ mod tests {
895895
use super::*;
896896

897897
use core::str::FromStr;
898-
use blockdata::constants::WITNESS_SCALE_FACTOR;
899-
use blockdata::script::Script;
900-
use consensus::encode::serialize;
901-
use consensus::encode::deserialize;
898+
use crate::blockdata::constants::WITNESS_SCALE_FACTOR;
899+
use crate::blockdata::script::Script;
900+
use crate::consensus::encode::serialize;
901+
use crate::consensus::encode::deserialize;
902902

903-
use hashes::Hash;
904-
use hashes::hex::FromHex;
903+
use crate::hashes::Hash;
904+
use crate::hashes::hex::FromHex;
905905

906-
use hash_types::*;
906+
use crate::hash_types::*;
907907
use super::EcdsaSighashType;
908-
use util::sighash::SighashCache;
908+
use crate::util::sighash::SighashCache;
909909

910910
#[test]
911911
fn test_outpoint() {
@@ -958,8 +958,8 @@ mod tests {
958958

959959
#[test]
960960
fn test_is_coinbase () {
961-
use network::constants::Network;
962-
use blockdata::constants;
961+
use crate::network::constants::Network;
962+
use crate::blockdata::constants;
963963

964964
let genesis = constants::genesis_block(Network::Bitcoin);
965965
assert! (genesis.txdata[0].is_coin_base());

src/blockdata/witness.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
//! This module contains the [`Witness`] struct and related methods to operate on it
44
//!
55
6-
use blockdata::transaction::EcdsaSighashType;
7-
use consensus::encode::{Error, MAX_VEC_SIZE};
8-
use consensus::{Decodable, Encodable, WriteExt};
9-
use io::{self, Read, Write};
10-
use prelude::*;
6+
use crate::blockdata::transaction::EcdsaSighashType;
7+
use crate::consensus::encode::{Error, MAX_VEC_SIZE};
8+
use crate::consensus::{Decodable, Encodable, WriteExt};
9+
use crate::io::{self, Read, Write};
10+
use crate::prelude::*;
1111
use secp256k1::ecdsa;
12-
use VarInt;
12+
use crate::VarInt;
1313

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

303303
#[cfg(test)]
304304
mod test {
305-
use blockdata::transaction::EcdsaSighashType;
306-
use blockdata::witness::Witness;
307-
use consensus::{deserialize, serialize};
308-
use hashes::hex::{FromHex, ToHex};
309-
use Transaction;
310-
use secp256k1::ecdsa;
305+
use super::*;
306+
307+
use crate::consensus::{deserialize, serialize};
308+
use crate::hashes::hex::{FromHex, ToHex};
309+
use crate::Transaction;
310+
use crate::secp256k1::ecdsa;
311311

312312
#[test]
313313
fn test_push() {

src/consensus/encode.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@
2727
//! typically big-endian decimals, etc.)
2828
//!
2929
30-
use prelude::*;
30+
use crate::prelude::*;
3131

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

35-
use hashes::{sha256d, Hash, sha256};
36-
use hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader};
35+
use crate::hashes::{sha256d, Hash, sha256};
36+
use crate::hash_types::{BlockHash, FilterHash, TxMerkleNode, FilterHeader};
3737

38-
use io::{self, Cursor, Read};
38+
use crate::io::{self, Cursor, Read};
3939

40-
use util::endian;
41-
use util::psbt;
42-
use util::taproot::TapLeafHash;
43-
use hashes::hex::ToHex;
40+
use crate::util::endian;
41+
use crate::util::psbt;
42+
use crate::util::taproot::TapLeafHash;
43+
use crate::hashes::hex::ToHex;
4444

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

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

785785
#[test]
786786
fn serialize_int_test() {

src/consensus/params.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
//! chains (such as mainnet, testnet).
1919
//!
2020
21-
use network::constants::Network;
22-
use util::uint::Uint256;
21+
use crate::network::constants::Network;
22+
use crate::util::uint::Uint256;
2323

2424
/// Lowest possible difficulty for Mainnet. See comment on Params::pow_limit for more info.
2525
const MAX_BITS_BITCOIN: Uint256 = Uint256([

src/hash_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//! hash).
2121
//!
2222
23-
use hashes::{Hash, sha256, sha256d, hash160};
23+
use crate::hashes::{Hash, sha256, sha256d, hash160};
2424

2525
macro_rules! impl_hashencode {
2626
($hashtype:ident) => {

0 commit comments

Comments
 (0)