Skip to content

Commit 37719bd

Browse files
committed
Change MultiAddr to Multiaddr
Signed-off-by: Eval EXEC <[email protected]>
1 parent 76294bc commit 37719bd

File tree

25 files changed

+92
-92
lines changed

25 files changed

+92
-92
lines changed

.github/workflows/ci_integration_tests_macos.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
runs-on: macos-13
5555
steps:
5656
- uses: actions/checkout@v4
57-
- run: brew install tor
57+
- run: brew install tor go
5858
- run: |
5959
if [[ ${{ needs.prologue.outputs.os_skip }} == run ]] && [[ ${{ needs.prologue.outputs.job_skip }} == run ]];then
6060
devtools/ci/ci_main.sh

.github/workflows/ci_integration_tests_windows.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767
scoop bucket add extras
6868
scoop install llvm
6969
scoop install tor
70+
scoop install go
7071
- run: |
7172
if [[ ${{ needs.prologue.outputs.os_skip }} == run ]] && [[ ${{ needs.prologue.outputs.job_skip }} == run ]];then
7273
devtools/ci/ci_main.sh

.github/workflows/ci_linters_ubuntu.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
components: rustfmt, clippy
5858
- uses: actions/setup-go@v5
5959
with:
60-
go-version: '^1.20.14'
60+
go-version: 1.20
6161
- run: cargo fmt --all -- --check
6262
- run: sudo apt-get update && sudo apt-get install libssl-dev pkg-config libclang-dev -y
6363
- run: |

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

network/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ bloom-filters.workspace = true
3535
ckb-spawn.workspace = true
3636
bitflags.workspace = true
3737
p2p = { workspace = true, default-features = false }
38+
url.workspace = true
3839

3940
[target.'cfg(not(target_family = "wasm"))'.dependencies]
4041
p2p = { workspace = true, default-features = false, features = [

network/fuzz/fuzz_targets/fuzz_peer_store.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
use libfuzzer_sys::fuzz_target;
44

55
use ckb_network::{
6-
multiaddr::MultiAddr, peer_store::types::BannedAddr, peer_store::PeerStore, Flags, PeerId,
6+
multiaddr::Multiaddr, peer_store::types::BannedAddr, peer_store::PeerStore, Flags, PeerId,
77
};
88
use ckb_network_fuzz::BufManager;
99

10-
fn new_multi_addr(data: &mut BufManager) -> (MultiAddr, Flags) {
10+
fn new_multi_addr(data: &mut BufManager) -> (Multiaddr, Flags) {
1111
let flags = data.get();
1212
let addr_flag = data.get::<u8>();
1313

network/src/address.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use p2p::multiaddr::{MultiAddr, Protocol};
1+
use p2p::multiaddr::{Multiaddr, Protocol};
22

33
#[derive(Default, Clone, Debug)]
44
pub struct NetworkAddresses {
5-
pub regular_addresses: Vec<MultiAddr>,
5+
pub regular_addresses: Vec<Multiaddr>,
66

77
// onion addresses can't be solved by multiaddr_to_socketaddr or socketaddr_to_multiaddr
8-
pub onion_addresses: Vec<MultiAddr>,
8+
pub onion_addresses: Vec<Multiaddr>,
99
}
1010

1111
impl NetworkAddresses {
12-
pub fn push(&mut self, address: MultiAddr) {
12+
pub fn push(&mut self, address: Multiaddr) {
1313
if address
1414
.iter()
1515
.any(|proto| matches!(proto, Protocol::Onion3(_)))
@@ -21,7 +21,7 @@ impl NetworkAddresses {
2121
}
2222

2323
// contains
24-
pub fn contains(&self, address: &MultiAddr) -> bool {
24+
pub fn contains(&self, address: &Multiaddr) -> bool {
2525
self.regular_addresses.contains(address) || self.onion_addresses.contains(address)
2626
}
2727

@@ -38,9 +38,9 @@ impl NetworkAddresses {
3838

3939
// implement iter() for NetworkAddresses, don't take ownership
4040
impl<'a> IntoIterator for &'a NetworkAddresses {
41-
type Item = &'a MultiAddr;
41+
type Item = &'a Multiaddr;
4242
type IntoIter =
43-
std::iter::Chain<std::slice::Iter<'a, MultiAddr>, std::slice::Iter<'a, MultiAddr>>;
43+
std::iter::Chain<std::slice::Iter<'a, Multiaddr>, std::slice::Iter<'a, Multiaddr>>;
4444

4545
fn into_iter(self) -> Self::IntoIter {
4646
self.regular_addresses
@@ -49,9 +49,9 @@ impl<'a> IntoIterator for &'a NetworkAddresses {
4949
}
5050
}
5151

52-
// convert Vec<MultiAddr> to NetworkAddresses
53-
impl From<Vec<MultiAddr>> for NetworkAddresses {
54-
fn from(addresses: Vec<MultiAddr>) -> Self {
52+
// convert Vec<Multiaddr> to NetworkAddresses
53+
impl From<Vec<Multiaddr>> for NetworkAddresses {
54+
fn from(addresses: Vec<Multiaddr>) -> Self {
5555
let mut regular_addresses = Vec::new();
5656
let mut onion_addresses = Vec::new();
5757
for address in addresses {
@@ -71,8 +71,8 @@ impl From<Vec<MultiAddr>> for NetworkAddresses {
7171
}
7272
}
7373

74-
// convert NetworkAddresses to Vec<MultiAddr>
75-
impl From<NetworkAddresses> for Vec<MultiAddr> {
74+
// convert NetworkAddresses to Vec<Multiaddr>
75+
impl From<NetworkAddresses> for Vec<Multiaddr> {
7676
fn from(addresses: NetworkAddresses) -> Self {
7777
let mut result = addresses.regular_addresses;
7878
result.extend(addresses.onion_addresses);

network/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub type ProtocolVersion = String;
5656

5757
/// Observe listen port occupancy
5858
pub async fn observe_listen_port_occupancy(
59-
_addrs: &[multiaddr::MultiAddr],
59+
_addrs: &[multiaddr::Multiaddr],
6060
) -> Result<(), std::io::Error> {
6161
#[cfg(target_os = "linux")]
6262
{

network/src/network.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ impl NetworkState {
339339
}
340340

341341
pub(crate) fn public_addrs(&self, count: usize) -> Vec<Multiaddr> {
342-
if self.public_addrs.read().len() <= count {
343-
return self.public_addrs.read().iter().cloned().collect();
342+
let public_addrs = self.public_addrs.read();
343+
if public_addrs.len() <= count {
344+
return public_addrs.iter().cloned().collect();
344345
} else {
345-
self.public_addrs
346-
.read()
346+
public_addrs
347347
.iter()
348348
.cloned()
349349
.choose_multiple(&mut rand::thread_rng(), count)
@@ -1059,12 +1059,11 @@ impl NetworkService {
10591059
p2p::service::SocketState::Dial => {
10601060
let domain = socket2::Domain::for_address(addr);
10611061
if socket_ref.domain()? == domain {
1062-
let should_bind_socket = !(proxy_config_enable
1063-
&& matches!(ctxt.state, p2p::service::SocketState::Dial));
1064-
if should_bind_socket {
1065-
socket_ref.bind(&addr.into())?;
1066-
} else {
1062+
if proxy_config_enable {
10671063
// skip bind if proxy enabled
1064+
debug!("skip bind since proxy is enabled");
1065+
} else {
1066+
socket_ref.bind(&addr.into())?;
10681067
}
10691068
}
10701069
Ok(socket)

network/src/peer_store/addr_manager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Address manager
22
use crate::peer_store::{base_addr, types::AddrInfo};
3+
use ckb_logger::debug;
34
use p2p::{
45
multiaddr::{Multiaddr, Protocol},
56
utils::multiaddr_to_socketaddr,
@@ -81,7 +82,7 @@ impl AddrManager {
8182
addr_infos.push(addr_info);
8283
} else {
8384
debug!(
84-
"addr {:?} is not connectable or not onion address",
85+
"addr {:?} is not connectable and not an onion address",
8586
addr_info.addr
8687
);
8788
}

0 commit comments

Comments
 (0)