netdir: Conditionally expose some by_rsa APIs as experimental.
Network-health wants these to see whether a given relay is listed in the consensus. cc @juga
This commit is contained in:
parent
83552b559f
commit
7ac362eba7
|
@ -4590,6 +4590,7 @@ dependencies = [
|
|||
"tor-units",
|
||||
"tracing",
|
||||
"typed-index-collections",
|
||||
"visibility",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -20,7 +20,7 @@ experimental = ["experimental-api", "hs-service", "hs-client", "testing"]
|
|||
#
|
||||
# These APIs are not covered by semantic versioning. Using this
|
||||
# feature voids your "semver warrantee".
|
||||
experimental-api = ["__is_experimental"]
|
||||
experimental-api = ["visibility", "__is_experimental"]
|
||||
hs-client = ["hs-common", "__is_experimental"]
|
||||
hs-service = ["hs-common", "__is_experimental"]
|
||||
hs-common = ["digest", "hex", "time", "tor-hscrypto"]
|
||||
|
@ -72,6 +72,7 @@ tor-protover = { path = "../tor-protover", version = "0.5.1" }
|
|||
tor-units = { path = "../tor-units", version = "0.6.1" }
|
||||
tracing = "0.1.36"
|
||||
typed-index-collections = "3.1"
|
||||
visibility = { version = "0.0.1", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
float_eq = "1.0.0"
|
||||
|
|
|
@ -1051,7 +1051,13 @@ impl NetDir {
|
|||
}
|
||||
|
||||
/// Return a (possibly unusable) relay with a given RSA identity.
|
||||
///
|
||||
/// This API can be used to find information about a relay that is listed in
|
||||
/// the current consensus, even if we don't yet have enough information
|
||||
/// (like a microdescriptor) about the relay to use it.
|
||||
#[allow(clippy::missing_panics_doc)] // Can't panic on valid object.
|
||||
#[cfg_attr(feature = "experimental-api", visibility::make(pub))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "experimental-api")))]
|
||||
fn by_rsa_id_unchecked(&self, rsa_id: &RsaIdentity) -> Option<UncheckedRelay<'_>> {
|
||||
let rsidx = *self.rsidx_by_rsa.get(rsa_id)?;
|
||||
let rs = self.c_relays().get(rsidx).expect("Corrupt index");
|
||||
|
@ -1063,8 +1069,13 @@ impl NetDir {
|
|||
fn by_rsa_id(&self, rsa_id: &RsaIdentity) -> Option<Relay<'_>> {
|
||||
self.by_rsa_id_unchecked(rsa_id)?.into_relay()
|
||||
}
|
||||
/// Return true if `rsa_id` is listed in this directory, even if it
|
||||
/// isn't currently usable.
|
||||
/// Return true if `rsa_id` is listed in this directory, even if it isn't
|
||||
/// currently usable.
|
||||
///
|
||||
/// (An "unusable" relay in this context is one for which we don't have full
|
||||
/// directory information.)
|
||||
#[cfg_attr(feature = "experimental-api", visibility::make(pub))]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "experimental-api")))]
|
||||
fn rsa_id_is_listed(&self, rsa_id: &RsaIdentity) -> bool {
|
||||
self.by_rsa_id_unchecked(rsa_id).is_some()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue