Skip to content

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:

  • DirMgr needs uses CircMgr to make BEGINDIR circuits, so it has to exist at a higher level than CircMgr. That means that you can't easily give CircMgr a reference to the DirMgr that would give it a NetDir without doing something to break circularity.
  • The DirMgr design is more efficient if nobody ever keeps a reference to a NetDir longer than they need to. (See SharedMutArc::mutate() and register_microdescs in DirMgr.)
  • For testing, it's actually pretty convenient for most CircMgr APIs to sometimes take a NetDir as 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.