client/authority-discovery: Limit number of connections to authorities (#4487)
* client/authority-discovery: Limit number of connections to authorities Instead of connecting to all sentry nodes of all authorities, with this patch the authority discovery module does the following: - Choose one sentry node per authority at random. - Choose MAX_NUM_AUTHORITY_CONN out of the above at random. The module uses randomness to prevent hot spots, e.g. all nodes trying to connect to a single node. If the authority discovery module would choose the nodes to connect to at random on each new address that it learns of, the node would go through a lot of connection churn. Instead it creates a random seed at start up and uses this seed for its RNG on each update cycle. * client/authority-discovery: Extract address cache into own module * client/authority-discovery/src/addr_cache: Add basic unit tests * client/authority-discovery: Replace unwrap with expect on [u8] cmp * .maintain/sentry-node/docker-compose.yml: Prefix endpoint flags * client/authority-discovery/src/addr_cache: Use sort_unstable and cmp * client/authority-discovery: Use BTreeMap in addr_cache for sorted iter To reduce connection churn it is preferrable to have `get_subset` of the `addr_cache` to return the same result on repeated calls. `get_subset` iterates a map. To make the process of iteration deterministic, use a `BTreeMap` instead of a `HashMap`.
parent
fa1e42a2
Please register or sign in to comment