I'm adding a local "Buildable" trait here so I can swap out Circuits
for something else. This also lets me refactor Builder<> to be
parameterized on TimeoutEstimator again, and lets us get rid of the
first_hop() accessor on paths.
There is something wrong here, though. I had to rewrite wait_for() a
lot back in the main branch to get this test working right. See
arti#149 for details on that issue.
This backend uses the kludged-up^W heuristic-enhanced Pareto
estimator from path-spec.txt section 2.4. See path-spec.txt for
full details on the algorithm. I've tried to note with TODO-SPEC
comments all the things that the spec currently leaves out.
Nothing actually uses this code yet. By the time it's in use, I'd
expect that many of these functions will need to have new
visibilities.
Previously this was done in functions associated with Path and
OwnedPath, but this caused their method signatures to get more and
more complicated.
This change will also allow us to make timeout handling part of the
circuit-building process.
Thanks to cargo's version-2 feature resolver, we can require a
runtime for tests only.
I'm also making it so that the functions that create or fetch
Runtimes only exist when one of the runtime features is enabled.
For now that seems like a better solution than having those
functions exist but panic.
Closes#129.
As with the tor-chanmgr code, the circuit manager is now implemented
using an AbstractCircMgr type that uses traits to abstract the
particular behavior of other types that it uses. (Specifically:
circuits, building circuits, and telling whether one circuit usage
is compatible with another.) Abstracting out the dependencies in
this ways makes it possible to test the circuit manager without
having to actually build real circuits.
This commit also introduces new behavior for handling pending
circuit requests. Upon getting a new request, first we check to see
if there's an existing circuit we can use. If there isn't, we look
for pending circuits and wait for them. If there aren't any pending
circuits we can use, we launch one or more, and wait for them.
So far, that's the same as the old behavior. But here's a change:
if, while we are waiting for some pending circuits, a different
circuit is completed, and it's one we could use, then the task that
was building _that_ circuit will tell us: "please look at this
circuit". This gives us better changes of getting a usable circuit
fast.
Minor changes:
* The Error type in CircMgr no longer uses anyhow; several errors
have been simplified.
* We've gotten more formal about the relationship between circuit
usage and target usage.