Expose and collect bootstrap status information from tor-chanmgr and tor-dirmgr
This branch adds functionality, based on postage::watch
, to export bootstrap status information from tor-dirmgr and tor-chanmgr. I expect that the content of the information will change in the future, so I've made the interfaces somewhat opaque.
Implements a first cut of #96 (closed), though we will need to refine it in the future.
Some of the information that we collect in this branch is more than strictly needed for the bootstrap data that we expose right now. I hope this isn't confusing: I think that in the future we'll probably move to collect less, or use the data that we collect in a more sophisticated way, or some of each.
I've done a trick in tor-chanmgr to avoid creating events too frequently, since otherwise it would lead to many spurious changes. If we decide to make that change elsewhere too, I think we can safely do so in a later commit.
As it stands, this branch isn't completely useful on its own, since there is no way currently to get an un-bootstrapped TorClient
. It will require #293 (closed) for that. (@eta, please let me know if the changes this makes to TorClient
will conflict with your plans there.)
NOTE: Please see the individual commit messages for more information about design rationale, tradeoffs, and future work.
Merge request reports
Activity
changed milestone to %Arti 0.1.0 release: Okay for experimental embedding
requested review from @eta
assigned to @nickm
113 114 /// How should we get the consensus from the cache, if at all? 114 115 cache_usage: CacheUsage, 115 116 117 /// If present, a time that we want our consensus to have been published. - crates/tor-chanmgr/src/event.rs 0 → 100644
36 /// Return true if this status is equal to `other`. 37 /// 38 /// Note:(This would just be a PartialEq implementation, but I'm not sure I 39 /// want to expose that PartialEq for this struct.) 40 fn eq(&self, other: &ConnStatus) -> bool { 41 self.online == other.online && self.tls_works == other.tls_works 42 } 43 44 /// Return true if this status indicates that we can successfully open Tor channels. 45 pub fn usable(&self) -> bool { 46 self.online == Some(true) && self.tls_works == Some(true) 47 } 48 49 /// Return a float representing "how bootstrapped" we are with respect to 50 /// connecting to the Tor network, where 0 is "not at all" and 1 is 51 /// "successful". - crates/tor-chanmgr/src/event.rs 0 → 100644
1 //! Code for exporting events from the channel manager. 2 #![allow(dead_code, unreachable_pub)] 3 4 use futures::{Stream, StreamExt}; 5 use postage::watch; 6 use std::{ 7 fmt, 8 time::{Duration, Instant}, 9 }; 10 11 /// The status of our connection to the internet. 12 #[derive(Default, Debug, Clone)] 13 pub struct ConnStatus { 14 /// True if we've been able to make outgoing connections recently. 15 /// False if we've definitely been failing.