Skip to content

Commit 39d488b

Browse files
committed
Merge rust-bitcoin#5342: Depend on primitives instead of bitcoin where type definitions overlap
c97d458 Add re-export for primitives to Bitcoin crate (yancy) f81e8d2 Depend on primitives instead of bitcoin where type definitions overlap (yancy) Pull request description: Consolidate dependency tree for downstream crates that depend on `bitcoin-p2p-messages` by reducing overlapping dependencies. For example, consider crate A which depends on `bitcoin-primitives` and `bitcoin-p2p-messages`. For types defined by both `bitcoin-primitives` and `bitcoin`, Crate A may still need to depend on `bitcoin` if a type of `bitcoin-p2p-messages` depends on `bitcoin` instead of `bitcoin-primitives`. Also, see: rust-bitcoin#5331 _After_ this change, the remaining bitcoin dependencies are: ``` examples/handshake.rs:6:use bitcoin::consensus::{encode, Decodable}; src/address.rs:15:use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt}; src/address.rs:532: use bitcoin::consensus::encode::{deserialize, serialize}; src/consensus.rs:2:use bitcoin::consensus::encode::WriteExt; src/lib.rs:43:use bitcoin::consensus::encode::{self, Decodable, Encodable}; src/lib.rs:44:use bitcoin::network::{Network, Params, TestnetVersion}; src/lib.rs:489: use bitcoin::consensus::encode::{deserialize, serialize}; src/message.rs:17:use bitcoin::block::HeaderExt; src/message.rs:18:use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt}; src/message.rs:19:use bitcoin::merkle_tree::MerkleBlock; src/message.rs:959: use bitcoin::bip152::BlockTransactionsRequest; src/message.rs:960: use bitcoin::bip158::{FilterHash, FilterHeader}; src/message.rs:962: use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize}; src/message_blockdata.rs:13:use bitcoin::consensus::encode::{self, Decodable, Encodable}; src/message_blockdata.rs:175: use bitcoin::consensus::encode::{deserialize, serialize}; src/message_bloom.rs:11:use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt}; src/message_compact_blocks.rs:8:use bitcoin::bip152; src/message_filter.rs:11:use bitcoin::bip158::{FilterHash, FilterHeader}; src/message_network.rs:15:use bitcoin::consensus::{encode, Decodable, Encodable, ReadExt, WriteExt}; src/message_network.rs:420: use bitcoin::consensus::encode::{deserialize, serialize}; src/network_ext.rs:7:use bitcoin::{Network, TestnetVersion}; ``` I've left bip152 and bip158 for future PRs (rust-bitcoin#5333). I don't think any of the remaining dependencies can be readily moved. ACKs for top commit: apoelstra: ACK c97d458; successfully ran local tests tcharding: ACK c97d458 Tree-SHA512: 389eb09d8b3a75de0cb30baa3722c9e7b03273dfb8547211246349e97ab205c66354aaed2a49415faf6e01fef41a496d114fb68869355f95778f69e2346bb8c6
2 parents 8b705e9 + c97d458 commit 39d488b

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

Cargo-minimal.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ dependencies = [
131131
"bitcoin-consensus-encoding",
132132
"bitcoin-internals",
133133
"bitcoin-io",
134+
"bitcoin-primitives",
134135
"bitcoin-units",
135136
"bitcoin_hashes",
136137
"hex-conservative 0.3.0",

Cargo-recent.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ dependencies = [
130130
"bitcoin-consensus-encoding",
131131
"bitcoin-internals",
132132
"bitcoin-io",
133+
"bitcoin-primitives",
133134
"bitcoin-units",
134135
"bitcoin_hashes",
135136
"hex-conservative 0.3.0",

bitcoin/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ pub extern crate hex;
7474
/// Re-export the `bitcoin-io` crate.
7575
pub extern crate io;
7676

77+
/// Re-export the `primitives` crate.
78+
pub extern crate primitives;
79+
7780
/// Re-export the `rust-secp256k1` crate.
7881
///
7982
/// Rust wrapper library for Pieter Wuille's libsecp256k1. Implements ECDSA and BIP-0340 signatures

p2p/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ exclude = ["tests", "contrib"]
1414

1515
[features]
1616
default = ["std"]
17-
std = ["encoding/std", "hashes/std", "hex/std", "internals/std", "io/std", "units/std", "bitcoin/std"]
17+
std = ["encoding/std", "hashes/std", "hex/std", "internals/std", "io/std", "units/std", "bitcoin/std", "primitives/std"]
1818
arbitrary = ["dep:arbitrary", "bitcoin/arbitrary"]
1919

2020
[dependencies]
2121
bitcoin = { path = "../bitcoin/", default-features = false }
2222
encoding = { package = "bitcoin-consensus-encoding", version = "=1.0.0-rc.2", path = "../consensus_encoding", default-features = false }
2323
hashes = { package = "bitcoin_hashes", version = "0.18.0", path = "../hashes", default-features = false }
24+
primitives = { package = "bitcoin-primitives", path = "../primitives", version = "=1.0.0-rc.1", default-features = false }
2425
hex = { package = "hex-conservative", version = "0.3.0", default-features = false }
2526
internals = { package = "bitcoin-internals", path = "../internals", default-features = false }
2627
io = { package = "bitcoin-io", path = "../io", default-features = false }

p2p/src/message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use core::{cmp, fmt};
1616
use arbitrary::{Arbitrary, Unstructured};
1717
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
1818
use bitcoin::merkle_tree::MerkleBlock;
19-
use bitcoin::{block, transaction};
19+
use primitives::{block, transaction};
2020
use encoding;
2121
use hashes::sha256d;
2222
use internals::ToU64 as _;
@@ -1660,9 +1660,9 @@ mod test {
16601660
use alloc::vec;
16611661
use std::net::Ipv4Addr;
16621662

1663-
use bitcoin::block::{Block, BlockHash};
1663+
use primitives::{Block, BlockHash};
16641664
use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize};
1665-
use bitcoin::transaction::{Transaction, Txid};
1665+
use primitives::transaction::{Transaction, Txid};
16661666
use hex_lit::hex;
16671667
use units::BlockHeight;
16681668

p2p/src/message_blockdata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use alloc::vec::Vec;
99

1010
#[cfg(feature = "arbitrary")]
1111
use arbitrary::{Arbitrary, Unstructured};
12-
use bitcoin::block::BlockHash;
12+
use primitives::BlockHash;
1313
use bitcoin::consensus::encode::{self, Decodable, Encodable};
14-
use bitcoin::transaction::{Txid, Wtxid};
14+
use primitives::transaction::{Txid, Wtxid};
1515
use io::{BufRead, Write};
1616

1717
use crate::consensus::impl_consensus_encoding;

p2p/src/message_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use alloc::vec::Vec;
88

99
#[cfg(feature = "arbitrary")]
1010
use arbitrary::{Arbitrary, Unstructured};
11-
use bitcoin::block::BlockHash;
11+
use primitives::BlockHash;
1212
use hashes::{sha256d, HashEngine};
1313
use units::BlockHeight;
1414

0 commit comments

Comments
 (0)