Skip to content

Commit 05a78ad

Browse files
committed
Remove network module
The `bitcoin-p2p` crate now handles DNS queries. In the future it will likely also handled Socks5
1 parent 2819091 commit 05a78ad

File tree

8 files changed

+10
-332
lines changed

8 files changed

+10
-332
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[workspace]
2-
members = ["accumulator", "hintfile", "network", "node"]
3-
default-members = ["accumulator", "network"]
2+
members = ["accumulator", "hintfile", "node"]
3+
default-members = ["accumulator"]
44
resolver = "2"
55

66
[workspace.dependencies]
77
bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", default-features = false, rev = "16cc257c3695dea0e7301a5fa9cab44b8ed60598" }
88
kernel = { package = "bitcoinkernel", git = "https://github.com/alexanderwiederin/rust-bitcoinkernel.git", rev = "353533221e3ba91d672418eab1ae7b83a61214f9" }
9-
p2p = { package = "bitcoin-p2p", git = "https://github.com/2140-dev/bitcoin-p2p.git", rev = "4f67fbeced98e3ddcc65a1333c46823a2b56332a" }
9+
p2p = { package = "bitcoin-p2p", git = "https://github.com/2140-dev/bitcoin-p2p.git", rev = "44fbf6a50aec6cd8a30301deff438b7436069106" }

network/Cargo.toml

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

network/README.md

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

network/src/dns.rs

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

network/src/lib.rs

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

network/tests/test.rs

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

node/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ accumulator = { path = "../accumulator/" }
99
bitcoin = { workspace = true }
1010
kernel = { workspace = true }
1111
hintfile = { path = "../hintfile/" }
12-
network = { path = "../network/" }
1312
p2p = { workspace = true }
1413

1514
configure_me = "0.4.0"

node/src/lib.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{
22
collections::HashSet,
33
fs::File,
44
io::Write,
5-
net::SocketAddr,
5+
net::{IpAddr, Ipv4Addr, SocketAddr},
66
path::Path,
77
sync::{
88
mpsc::{Receiver, Sender},
@@ -21,16 +21,16 @@ use bitcoin::{
2121
};
2222
use hintfile::Hints;
2323
use kernel::{ChainType, ChainstateManager};
24-
use network::dns::DnsQuery;
2524
use p2p::{
25+
dns::DnsQueryExt,
2626
handshake::ConnectionConfig,
2727
net::{ConnectionExt, TimeoutParams},
2828
p2p::{
2929
message::{InventoryPayload, NetworkMessage},
3030
message_blockdata::{GetHeadersMessage, Inventory},
3131
NetworkExt, ProtocolVersion, ServiceFlags,
3232
},
33-
SeedsExt, TimedMessage,
33+
TimedMessage,
3434
};
3535

3636
const PROTOCOL_VERSION: ProtocolVersion = ProtocolVersion::WTXID_RELAY_VERSION;
@@ -64,14 +64,11 @@ impl AccumulatorState {
6464
}
6565

6666
pub fn bootstrap_dns(network: Network) -> Vec<SocketAddr> {
67-
let mut all_hosts = Vec::new();
68-
for seed in network.seeds() {
69-
let hosts = DnsQuery::new_cloudflare(seed).lookup().unwrap_or_default();
70-
all_hosts.extend_from_slice(&hosts);
71-
}
72-
all_hosts
67+
let cloudflare = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(1, 1, 1, 1)), 53);
68+
network
69+
.query_dns_seeds(cloudflare)
7370
.into_iter()
74-
.map(|host| SocketAddr::new(host, network.default_p2p_port()))
71+
.map(|ip| SocketAddr::new(ip, network.default_p2p_port()))
7572
.collect()
7673
}
7774

0 commit comments

Comments
 (0)