Maybe refactor CircMgr to get NetDir objects directly?
There are several places where CircMgr's interface takes a NetDir or DirInfo object as an argument. This mostly works, but there are a few places where it makes things inconvenient.
Notably, it requires arti-tor-client to pass messages from the DirMgr to the CircMgr when the directory or network parameters change. It also requires arti-tor-client to periodically invoke launch_timeout_testing_circuit_if_appropriate. Both of these functions would be better handled as part of tor-circmgr crate, I think.
But there are some factors that make it hard to let CircMgr get a NetDir directly:
-
DirMgrneeds usesCircMgrto make BEGINDIR circuits, so it has to exist at a higher level thanCircMgr. That means that you can't easily giveCircMgra reference to theDirMgrthat would give it aNetDirwithout doing something to break circularity. - The
DirMgrdesign is more efficient if nobody ever keeps a reference to aNetDirlonger than they need to. (SeeSharedMutArc::mutate()andregister_microdescsinDirMgr.) - For testing, it's actually pretty convenient for most
CircMgrAPIs to sometimes take aNetDiras an argument rather than have it stored as a member locally.
This will need some careful thought. Please reach out before hacking here: there are a lot of approaches that won't work, and any approach we do take has architectural implications for the future of Arti.