mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
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`.
This commit is contained in:
@@ -47,8 +47,8 @@ services:
|
||||
- "--reserved-nodes"
|
||||
- "/dns4/sentry-a/tcp/30333/p2p/QmV7EhW6J6KgmNdr558RH1mPx2xGGznW7At4BhXzntRFsi"
|
||||
# Not only bind to localhost.
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
- "--unsafe-ws-external"
|
||||
- "--unsafe-rpc-external"
|
||||
# - "--log"
|
||||
# - "sub-libp2p=trace"
|
||||
# - "--log"
|
||||
@@ -88,8 +88,8 @@ services:
|
||||
- "--rpc-cors"
|
||||
- "all"
|
||||
# Not only bind to localhost.
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
- "--unsafe-ws-external"
|
||||
- "--unsafe-rpc-external"
|
||||
- "--log"
|
||||
- "sub-authority-discovery=trace"
|
||||
- "--sentry"
|
||||
@@ -121,8 +121,8 @@ services:
|
||||
- "--rpc-cors"
|
||||
- "all"
|
||||
# Not only bind to localhost.
|
||||
- "--ws-external"
|
||||
- "--rpc-external"
|
||||
- "--unsafe-ws-external"
|
||||
- "--unsafe-rpc-external"
|
||||
- "--log"
|
||||
- "sub-authority-discovery=trace"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user