Add a function to look up a Relay by ChanTarget.

This commit is contained in:
Nick Mathewson 2021-10-11 15:21:46 -04:00
parent 34b576a815
commit 19038ae39a
1 changed files with 8 additions and 0 deletions

View File

@ -524,6 +524,14 @@ impl NetDir {
self.by_id(ed_id).filter(|r| r.rs.rsa_identity() == rsa_id)
}
/// Return the usable relay matching a given [`ChanTarget`]'s
/// identities, if any.
///
/// (Does not return unusable relays.)
pub fn by_chantarget(&self, chan_target: &impl tor_linkspec::ChanTarget) -> Option<Relay<'_>> {
self.by_id_pair(chan_target.ed_identity(), chan_target.rsa_identity())
}
/// Return a boolean if this consensus definitely has (or does not
/// have) a relay matching both the given Ed25519 and RSA
/// identity.