tor-guardmgr: Make lite vanguards work
The VanguardMgr
now has a background task that
- removes vanguards when their lifetime runs out
- repopulates each
VanguardSet
with new vanguards when the number of vanguards drops below the target size of the set - handles
NetDir
changes, updating the vanguard set sizes as needed, and discarding any vanguards that are no longer in the consensus
Another major change is that VanguardSet
no longer owns the TimeBoundVanguard
s it contains. Instead, it holds Weak
references to the vanguards, which are now owned by the VanguardMgr
. VanguardMgr
keeps all TimeBoundVanguards
, regardless of the Layer
they're used in, in a "min"-heap, ordered by expiration timestamp (since we need to periodically remove the expired vanguards, and determine which vanguard will expire next, it was convenient to just put them all in VanguardMgr
).
To test this patch, I had to extend TestNetDirProvider
with a set_netdir_and_notify
function that updates the underlying NetDir
and causes DirEvent::NewConsensus
event to fire.
Closes #1275 (closed) and #1340 (closed)