tor-proto: Add method for getting the HopNum of the last hop.

This commit is contained in:
Gabriela Moldovan 2023-07-31 19:52:38 +01:00
parent eee3bb8822
commit c23e85270e
No known key found for this signature in database
GPG Key ID: 3946E0ADE72BAC99
2 changed files with 15 additions and 0 deletions

View File

@ -7,3 +7,4 @@ and returns a `Result`
BREAKING: `ClientCirc::allow_stream_requests` now expects `self` to be
`&Arc<ClientCirc>`
ADDED: `HopNum` is now public
ADDED: `ClientCirc::last_hop_num`

View File

@ -283,6 +283,20 @@ impl ClientCirc {
}
}
/// Return the [`HopNum`](crate::HopNum) of the last hop of this circuit.
///
/// Returns an error if there is no last hop. (This should be impossible outside of the
/// tor-proto crate, but within the crate it's possible to have a circuit with no hops.)
pub fn last_hop_num(&self) -> Result<HopNum> {
Ok(self
.mutable
.lock()
.expect("poisoned lock")
.path
.last_hop_num()
.ok_or_else(|| internal!("no last hop index"))?)
}
/// Return a description of all the hops in this circuit.
///
/// This method is **deprecated** for several reasons: