Rename the network module to p2p
The `network` module deals with data types and logic related to internetworking bitcoind nodes, this is commonly referred to as the p2p layer. Rename the `network` module to `p2p` and fix all the paths.
This commit is contained in:
parent
dac97072a5
commit
1bac1fd518
|
@ -6,7 +6,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|||
use std::{env, process};
|
||||
|
||||
use bitcoin::consensus::{encode, Decodable};
|
||||
use bitcoin::network::{address, constants, message, message_network};
|
||||
use bitcoin::p2p::{address, constants, message, message_network};
|
||||
use bitcoin::secp256k1;
|
||||
use bitcoin::secp256k1::rand::Rng;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ use crate::blockdata::script::witness_version::{self, WitnessVersion};
|
|||
use crate::blockdata::script::{self, Script, ScriptBuf};
|
||||
use crate::crypto::key::{PublicKey, TapTweak, TweakedPublicKey, UntweakedPublicKey};
|
||||
use crate::hash_types::{PubkeyHash, ScriptHash};
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
use crate::prelude::*;
|
||||
use crate::taproot::TapNodeHash;
|
||||
|
||||
|
@ -996,7 +996,7 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use crate::crypto::key::PublicKey;
|
||||
use crate::network::constants::Network::{Bitcoin, Testnet};
|
||||
use crate::p2p::constants::Network::{Bitcoin, Testnet};
|
||||
|
||||
fn roundtrips(addr: &Address) {
|
||||
assert_eq!(
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::crypto::key::{self, KeyPair, PrivateKey, PublicKey};
|
|||
use crate::hash_types::XpubIdentifier;
|
||||
use crate::internal_macros::impl_bytes_newtype;
|
||||
use crate::io::Write;
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
use crate::prelude::*;
|
||||
|
||||
/// A chain code
|
||||
|
@ -866,7 +866,7 @@ mod tests {
|
|||
use super::ChildNumber::{Hardened, Normal};
|
||||
use super::*;
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::constants::Network::{self, Bitcoin};
|
||||
use crate::p2p::constants::Network::{self, Bitcoin};
|
||||
|
||||
#[test]
|
||||
fn test_parse_derivation_path() {
|
||||
|
|
|
@ -20,7 +20,7 @@ use crate::blockdata::script;
|
|||
use crate::blockdata::transaction::{OutPoint, Sequence, Transaction, TxIn, TxOut};
|
||||
use crate::blockdata::witness::Witness;
|
||||
use crate::internal_macros::impl_bytes_newtype;
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
use crate::pow::CompactTarget;
|
||||
use crate::Amount;
|
||||
|
||||
|
@ -198,7 +198,7 @@ mod test {
|
|||
use crate::blockdata::locktime::absolute;
|
||||
use crate::consensus::encode::serialize;
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
|
||||
#[test]
|
||||
fn bitcoin_genesis_first_transaction() {
|
||||
|
|
|
@ -68,7 +68,7 @@ impl OutPoint {
|
|||
///
|
||||
/// ```rust
|
||||
/// use bitcoin::constants::genesis_block;
|
||||
/// use bitcoin::network::constants::Network;
|
||||
/// use bitcoin::p2p::constants::Network;
|
||||
///
|
||||
/// let block = genesis_block(Network::Bitcoin);
|
||||
/// let tx = &block.txdata[0];
|
||||
|
@ -1508,7 +1508,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_is_coinbase() {
|
||||
use crate::blockdata::constants;
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
|
||||
let genesis = constants::genesis_block(Network::Bitcoin);
|
||||
assert!(genesis.txdata[0].is_coinbase());
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::blockdata::transaction::{Transaction, TxIn, TxOut};
|
|||
use crate::hash_types::{BlockHash, FilterHash, FilterHeader, TxMerkleNode};
|
||||
use crate::io::{self, Cursor, Read};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::network::{
|
||||
use crate::p2p::{
|
||||
address::{AddrV2Message, Address},
|
||||
message_blockdata::Inventory,
|
||||
};
|
||||
|
@ -836,7 +836,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::consensus::{deserialize_partial, Decodable, Encodable};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::network::{message_blockdata::Inventory, Address};
|
||||
use crate::p2p::{message_blockdata::Inventory, Address};
|
||||
|
||||
#[test]
|
||||
fn serialize_int_test() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//! chains (such as mainnet, testnet).
|
||||
//!
|
||||
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
use crate::pow::Work;
|
||||
|
||||
/// Parameters that influence chain consensus.
|
||||
|
|
|
@ -18,7 +18,7 @@ pub use secp256k1::{self, constants, KeyPair, Parity, Secp256k1, Verification, X
|
|||
|
||||
use crate::crypto::ecdsa;
|
||||
use crate::hash_types::{PubkeyHash, WPubkeyHash};
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
use crate::prelude::*;
|
||||
use crate::taproot::{TapNodeHash, TapTweakHash};
|
||||
use crate::{base58, io};
|
||||
|
@ -741,7 +741,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::address::Address;
|
||||
use crate::io;
|
||||
use crate::network::constants::Network::{Bitcoin, Testnet};
|
||||
use crate::p2p::constants::Network::{Bitcoin, Testnet};
|
||||
|
||||
#[test]
|
||||
fn test_key_derivation() {
|
||||
|
|
|
@ -1120,7 +1120,7 @@ mod tests {
|
|||
use crate::crypto::key::PublicKey;
|
||||
use crate::crypto::sighash::{LegacySighash, TapSighash};
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::constants::Network;
|
||||
use crate::p2p::constants::Network;
|
||||
use crate::taproot::TapLeafHash;
|
||||
|
||||
extern crate serde_json;
|
||||
|
|
|
@ -92,7 +92,7 @@ mod parse;
|
|||
mod serde_utils;
|
||||
|
||||
#[macro_use]
|
||||
pub mod network;
|
||||
pub mod p2p;
|
||||
pub mod address;
|
||||
pub mod amount;
|
||||
pub mod base58;
|
||||
|
@ -146,7 +146,7 @@ pub use crate::hash_types::{
|
|||
BlockHash, PubkeyHash, ScriptHash, Txid, WPubkeyHash, WScriptHash, Wtxid,
|
||||
};
|
||||
pub use crate::merkle_tree::MerkleBlock;
|
||||
pub use crate::network::constants::Network;
|
||||
pub use crate::p2p::constants::Network;
|
||||
pub use crate::pow::{CompactTarget, Target, Work};
|
||||
pub use crate::psbt::Psbt;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSoc
|
|||
|
||||
use crate::consensus::encode::{self, Decodable, Encodable, ReadExt, VarInt, WriteExt};
|
||||
use crate::io;
|
||||
use crate::network::constants::ServiceFlags;
|
||||
use crate::p2p::constants::ServiceFlags;
|
||||
use crate::prelude::*;
|
||||
|
||||
/// A message which can be sent on the Bitcoin network
|
||||
|
@ -311,7 +311,7 @@ mod test {
|
|||
use super::{AddrV2, AddrV2Message, Address};
|
||||
use crate::consensus::encode::{deserialize, serialize};
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::constants::ServiceFlags;
|
||||
use crate::p2p::constants::ServiceFlags;
|
||||
|
||||
#[test]
|
||||
fn serialize_address_test() {
|
|
@ -16,7 +16,7 @@
|
|||
//! # Example: encoding a network's magic bytes
|
||||
//!
|
||||
//! ```rust
|
||||
//! use bitcoin::network::constants::Network;
|
||||
//! use bitcoin::p2p::constants::Network;
|
||||
//! use bitcoin::consensus::encode::serialize;
|
||||
//!
|
||||
//! let network = Network::Bitcoin;
|
||||
|
@ -82,7 +82,7 @@ impl Network {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use bitcoin::network::constants::{Network, Magic};
|
||||
/// use bitcoin::p2p::constants::{Network, Magic};
|
||||
/// use std::convert::TryFrom;
|
||||
///
|
||||
/// assert_eq!(Ok(Network::Bitcoin), Network::try_from(Magic::from_bytes([0xF9, 0xBE, 0xB4, 0xD9])));
|
||||
|
@ -96,7 +96,7 @@ impl Network {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use bitcoin::network::constants::{Network, Magic};
|
||||
/// use bitcoin::p2p::constants::{Network, Magic};
|
||||
///
|
||||
/// let network = Network::Bitcoin;
|
||||
/// assert_eq!(network.magic(), Magic::from_bytes([0xF9, 0xBE, 0xB4, 0xD9]));
|
||||
|
@ -148,7 +148,7 @@ impl Network {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use bitcoin::network::constants::Network;
|
||||
/// use bitcoin::p2p::constants::Network;
|
||||
/// use bitcoin::blockdata::constants::ChainHash;
|
||||
///
|
||||
/// let network = Network::Bitcoin;
|
||||
|
@ -161,7 +161,7 @@ impl Network {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use bitcoin::network::constants::Network;
|
||||
/// use bitcoin::p2p::constants::Network;
|
||||
/// use bitcoin::blockdata::constants::ChainHash;
|
||||
/// use std::convert::TryFrom;
|
||||
///
|
||||
|
@ -723,7 +723,7 @@ mod tests {
|
|||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||
#[serde(crate = "actual_serde")]
|
||||
struct T {
|
||||
#[serde(with = "crate::network::constants::as_core_arg")]
|
||||
#[serde(with = "crate::p2p::constants::as_core_arg")]
|
||||
pub network: Network,
|
||||
}
|
||||
|
|
@ -16,9 +16,9 @@ use crate::blockdata::{block, transaction};
|
|||
use crate::consensus::encode::{self, CheckedData, Decodable, Encodable, VarInt};
|
||||
use crate::io;
|
||||
use crate::merkle_tree::MerkleBlock;
|
||||
use crate::network::address::{AddrV2Message, Address};
|
||||
use crate::network::constants::Magic;
|
||||
use crate::network::{
|
||||
use crate::p2p::address::{AddrV2Message, Address};
|
||||
use crate::p2p::constants::Magic;
|
||||
use crate::p2p::{
|
||||
message_blockdata, message_bloom, message_compact_blocks, message_filter, message_network,
|
||||
};
|
||||
use crate::prelude::*;
|
||||
|
@ -549,12 +549,12 @@ mod test {
|
|||
use crate::blockdata::transaction::Transaction;
|
||||
use crate::consensus::encode::{deserialize, deserialize_partial, serialize};
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::address::{AddrV2, AddrV2Message, Address};
|
||||
use crate::network::constants::{Magic, Network, ServiceFlags};
|
||||
use crate::network::message_blockdata::{GetBlocksMessage, GetHeadersMessage, Inventory};
|
||||
use crate::network::message_bloom::{BloomFlags, FilterAdd, FilterLoad};
|
||||
use crate::network::message_compact_blocks::{GetBlockTxn, SendCmpct};
|
||||
use crate::network::message_filter::{
|
||||
use crate::p2p::address::{AddrV2, AddrV2Message, Address};
|
||||
use crate::p2p::constants::{Magic, Network, ServiceFlags};
|
||||
use crate::p2p::message_blockdata::{GetBlocksMessage, GetHeadersMessage, Inventory};
|
||||
use crate::p2p::message_bloom::{BloomFlags, FilterAdd, FilterLoad};
|
||||
use crate::p2p::message_compact_blocks::{GetBlockTxn, SendCmpct};
|
||||
use crate::p2p::message_filter::{
|
||||
CFCheckpt, CFHeaders, CFilter, GetCFCheckpt, GetCFHeaders, GetCFilters,
|
||||
};
|
||||
|
|
@ -12,7 +12,7 @@ use crate::consensus::encode::{self, Decodable, Encodable};
|
|||
use crate::hash_types::{BlockHash, Txid, Wtxid};
|
||||
use crate::internal_macros::impl_consensus_encoding;
|
||||
use crate::io;
|
||||
use crate::network::constants;
|
||||
use crate::p2p::constants;
|
||||
use crate::prelude::*;
|
||||
|
||||
/// An inventory item.
|
|
@ -11,8 +11,8 @@ use hashes::sha256d;
|
|||
use crate::consensus::{encode, Decodable, Encodable, ReadExt};
|
||||
use crate::internal_macros::impl_consensus_encoding;
|
||||
use crate::io;
|
||||
use crate::network::address::Address;
|
||||
use crate::network::constants::{self, ServiceFlags};
|
||||
use crate::p2p::address::Address;
|
||||
use crate::p2p::constants::{self, ServiceFlags};
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Some simple messages
|
||||
|
@ -146,7 +146,7 @@ mod tests {
|
|||
use super::{Reject, RejectReason, VersionMessage};
|
||||
use crate::consensus::encode::{deserialize, serialize};
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::constants::ServiceFlags;
|
||||
use crate::p2p::constants::ServiceFlags;
|
||||
|
||||
#[test]
|
||||
fn version_message_test() {
|
|
@ -1,10 +1,9 @@
|
|||
// SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
//! Bitcoin network support.
|
||||
//! Bitcoin p2p network types.
|
||||
//!
|
||||
//! This module defines support for (de)serialization and network transport
|
||||
//! of Bitcoin data and network messages.
|
||||
//!
|
||||
//! of Bitcoin data and Bitcoin p2p network messages.
|
||||
|
||||
pub mod constants;
|
||||
|
|
@ -823,7 +823,7 @@ mod tests {
|
|||
use crate::blockdata::transaction::{OutPoint, Sequence, Transaction, TxIn, TxOut};
|
||||
use crate::blockdata::witness::Witness;
|
||||
use crate::internal_macros::hex;
|
||||
use crate::network::constants::Network::Bitcoin;
|
||||
use crate::p2p::constants::Network::Bitcoin;
|
||||
use crate::psbt::map::{Input, Output};
|
||||
use crate::psbt::raw;
|
||||
use crate::psbt::serialize::{Deserialize, Serialize};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
let _: Result<bitcoin::network::message::RawNetworkMessage, _> =
|
||||
let _: Result<bitcoin::p2p::message::RawNetworkMessage, _> =
|
||||
bitcoin::consensus::encode::deserialize(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use bitcoin::address::Address;
|
||||
use bitcoin::blockdata::script;
|
||||
use bitcoin::consensus::encode;
|
||||
use bitcoin::network::constants::Network;
|
||||
use bitcoin::p2p::constants::Network;
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
fn do_test(data: &[u8]) {
|
||||
|
|
Loading…
Reference in New Issue