Skip to content

Commit d9cf727

Browse files
committed
Move bitcoin/p2p into p2p
Moves all of the content from `bitcoin/p2p` into `p2p`. `TryFrom<Network>` must be implemented for `Network -> Magic` now that `Network` is a foreign, non-exhaustive type. Ser/de test is updated accordingly, as well as the `Magic::from_network` constructor, which I have opted to return an `Option<Self>`. The `TryFrom` implementation uses a new `UnknownNetworkError(Network)` that mirrors the `Magic -> Network` error. The example handshake does not generate a random nonce for the version message, as there is no `rand` dependency in this crate and the program only makes a single, user-defined connection. It appears we can do better than copying and pasting the consensus encoding macros and functions from `bitcoin` without doing weird cross-crate macros that require some special knowledge of the crate to know when they will compile.
1 parent 9852732 commit d9cf727

20 files changed

+687
-613
lines changed

Cargo-minimal.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ name = "bitcoin-fuzz"
7777
version = "0.0.1"
7878
dependencies = [
7979
"bitcoin",
80+
"bitcoin-p2p-messages",
8081
"honggfuzz",
8182
"serde",
8283
"serde_json",
@@ -109,6 +110,15 @@ dependencies = [
109110
[[package]]
110111
name = "bitcoin-p2p-messages"
111112
version = "0.1.0"
113+
dependencies = [
114+
"bitcoin",
115+
"bitcoin-internals",
116+
"bitcoin-io 0.2.0",
117+
"bitcoin-units",
118+
"bitcoin_hashes 0.16.0",
119+
"hex-conservative 0.3.0",
120+
"hex_lit",
121+
]
112122

113123
[[package]]
114124
name = "bitcoin-primitives"

Cargo-recent.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ name = "bitcoin-fuzz"
7676
version = "0.0.1"
7777
dependencies = [
7878
"bitcoin",
79+
"bitcoin-p2p-messages",
7980
"honggfuzz",
8081
"serde",
8182
"serde_json",
@@ -108,6 +109,15 @@ dependencies = [
108109
[[package]]
109110
name = "bitcoin-p2p-messages"
110111
version = "0.1.0"
112+
dependencies = [
113+
"bitcoin",
114+
"bitcoin-internals",
115+
"bitcoin-io 0.2.0",
116+
"bitcoin-units",
117+
"bitcoin_hashes 0.16.0",
118+
"hex-conservative 0.3.0",
119+
"hex_lit",
120+
]
111121

112122
[[package]]
113123
name = "bitcoin-primitives"

bitcoin/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ rustdoc-args = ["--cfg", "docsrs"]
5656
[[example]]
5757
name = "bip32"
5858

59-
[[example]]
60-
name = "handshake"
61-
required-features = ["rand-std"]
62-
6359
[[example]]
6460
name = "ecdsa-psbt"
6561
required-features = ["std", "bitcoinconsensus"]

bitcoin/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ extern crate serde;
9494
mod internal_macros;
9595

9696
#[macro_use]
97-
pub mod p2p;
9897
pub mod address;
9998
pub mod bip152;
10099
pub mod bip158;

bitcoin/src/p2p/deser.rs

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)