- ALL_GUARD_LIST = guard information from latest consensus
- GUARD_LIST = guards persisted to our state file
- DIRECTORY_GUARD = if we select guards with the V2Dir flag. Guards with the V2Dir Flag can be used as entry guards for both fetching information from directories as well as for standard entry guards.
- RECEIVE_NEW_CONSENSUS
- From listed guards in ALL_GUARD_LIST with DIRECTORY_GUARD=true:
1. 3 times do (default guard value on startup):
- ADD_RANDOM_ENTRYGUARD to choose a guard
- Add this new guard to GUARD_LIST
- Mark guards that are not listed in the latest consensus as "bad" in ALL_GUARD_LIST
- Remove guards that have been dead for 30 days from GUARD_LIST and ALL_GUARD_LIST
- Remove guards that were added more than 30 days ago from GUARD_LIST and ALL_GUARD_LIST
- First, CHOOSE_A_GUARD
- Then CONNECT_ENTRY_GUARD with our chosen guard
- Ensure that we have enough entry guards (only need 1)
1. If we do not:
- Use the ADD_RANDOM_ENTRYGUARD algorithm to choose a new guard, DIRECTORY_GUARD=false
- Add new guard to GUARD_LIST
- From GUARD_LIST of entry guards:
1. Build list of live guards, that are:
- listed in the current consensus, except if:
- It is offline and and we have previously tried 2. From this list of live guards
- Choose the number of guards that we need if the list contains:
- Guards that we have not tried, or
- Or if the list contains at least the number that we needed (which is 1) 3. Otherwise (if the list of live guards contains only 1):
- Relax our constraints (bandwidth, uptime, for directory, etc), and
- Use the ADD_RANDOM_ENTRYGUARD algorithm to choose a new guard
- Try to choose a new guard, starting over from b.
- Build weighted distribution of all guards based on bandwidth
- Pick a guard at random from this distribution
- If we have never made contact with this guard before:
1. If we can connect:
- Mark guard as we have made contact
- Assume the network was down, and mark all guards in GUARD_LIST for retry (except the guard that we just connected) 2. If we cannot connect:
- Remove it from GUARD_LIST
- [what is the fallback behavior? Do we choose another guard from GUARD_LIST]?
- If we have made contact with this guard before:
1. If we cannot connect:
- Mark this guard as offline