1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ---------------- [ File: bitcoin-network/src/check_is_reachable.rs ]
crate::ix!();
pub trait CheckIsReachable {
fn is_reachable(&self) -> bool;
}
impl CheckIsReachable for Network {
/**
| @return
|
| true if the network is reachable, false
| otherwise
|
*/
fn is_reachable(&self) -> bool {
todo!();
/*
LOCK(cs_mapLocalHost);
return !vfLimited[net];
*/
}
}
impl CheckIsReachable for NetAddr {
/**
| @return
|
| true if the address is in a reachable
| network, false otherwise
|
*/
fn is_reachable(&self) -> bool {
self.get_network().is_reachable()
}
}
#[cfg(test)]
mod reachability_trait_conformance_spec {
use super::*;
// Compile‑time conformance check: these functions will fail to compile if
// Network or NetAddr stop implementing the trait.
fn _assert_impl_check_is_reachable<T: CheckIsReachable>() {}
#[traced_test]
fn trait_is_implemented_for_network_and_netaddr() {
_assert_impl_check_is_reachable::<Network>();
_assert_impl_check_is_reachable::<NetAddr>();
info!("CheckIsReachable is implemented for Network and NetAddr (compile‑time assertion)");
assert!(true);
}
}