Skip to content

Add the ability to defer TorClient cache initialization

Ideally, it should be possible to create a minimal, unbootstrapped TorClient that doesn't access the cache_dir at all: arti hsc subcommand is implemented using the "porcelain" key management API from TorClient, which don't use the cache at all.

Right now, running multiple concurrent arti hsc commands doesn't work very well because TorClient::create_inner will occasionally fail to build the DirMgr (for example, if the cache_dir is missing, it fails due to a race in SqliteStore: when multiple artis processes share the same cache_dir, only one of them will have write access to the underlying sqlite store. However, if the db file is missing, all processes will try to create it, including the ones that only have read access). This makes testing the hsc subcommand very cumbersome (the tests run in parallel, so they'd all need to be set up to use a different cache_dir).

Note: this is a short-term fix for the lack of separation of concerns in the TorClient API (it consists of an assortment of functions, some of which don't need to connect to the Tor network at all). The long-term fix will involve rethinking those its APIs a bit (there will be a separate ticket for this).

Edited by gabi-250