Skip to content

Commit f81e8d2

Browse files
committed
Depend on primitives instead of bitcoin where type definitions overlap
Consolidate dependency tree for downstream crates that depend on `bitcoin-p2p-messages` and `bitcoin-primitives` 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`.
1 parent d1d8411 commit f81e8d2

File tree

6 files changed

+10
-7
lines changed

6 files changed

+10
-7
lines changed

Cargo-minimal.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",

Cargo-recent.lock

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

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 _;
@@ -1657,9 +1657,9 @@ mod test {
16571657
use alloc::vec;
16581658
use std::net::Ipv4Addr;
16591659

1660-
use bitcoin::block::{Block, BlockHash};
1660+
use primitives::{Block, BlockHash};
16611661
use bitcoin::consensus::encode::{deserialize, deserialize_partial, serialize};
1662-
use bitcoin::transaction::{Transaction, Txid};
1662+
use primitives::transaction::{Transaction, Txid};
16631663
use hex_lit::hex;
16641664
use units::BlockHeight;
16651665

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)