tor-guardmgr: Persist the vanguard sets if running in full vanguard mode
VanguardMgr
now supports running in "full" vanguard mode:
- I replaced
VanguardSet::new
withVanguardSet::default
:VanguardSet::new()
took a set ofVanguardParams
(from which it derived the target size of the set), but theVanguardSets
are supposed to be initialized on startup, when we don't have aVanguardParams
(we don't have the params until we obtain aNetDir
). Moreover, it doesn't make sense to even set the target size of theVanguardSet
before obtaining aNetDir
, because we can't actually populate the set without aNetDir
(we can't select relays). -
VanguardMgr
no longer has direct access to itsVanguardSet
s. It now holds aVanguardSets
(not to be confused withVanguardSet
) which is an abstraction over the L2 and L3 vanguard sets. Storing the two sets inVanguardSets
makes them easier to serialize and deserialize. It also enables us to track vanguard changes more easily (viaVanguardSetsTrackedMut
) -
VanguardSets
can't be directly mutated byVanguardMgr
. Instead, they are mutated through aVanguardSetsTrackedMut
handle, which enables us to track theVanguardSets
was actually mutated. This is useful because we only want to flush theVanguardSets
to storage if we added or removed some relays - I moved some of the vanguard management logic to
VanguardSets
. I think this makes the code easier to follow.
Closes #1273 (closed)