litep2p/peerset: Do not disconnect all peers on `SetReservedPeers` command (#6016)
Previously, when receiving the `SetReservedPeers { reserved }` all peers not in the `reserved` set were removed. This is incorrect, the intention of `SetReservedPeers` is to change the active set of reserved peers and disconnect previously reserved peers not in the new set. While at it, have added a few other improvements to make the peerset more robust: - `SetReservedPeers`: does not disconnect all peers - `SetReservedPeers`: if a reserved peer is no longer reserved, the peerset tries to move the peers to the regular set if the slots allow this move. This ensures the (now regular) peer counts towards slot allocation. - every 1 seconds: If we don't have enough connect peers, add the reserved peers to the list that the peerstore ignores. Reserved peers are already connected and the peerstore might return otherwise a reserved peer ### Next Steps - [x] More testing cc @paritytech/networking --------- Signed-off-by:Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by:
Dmitry Markin <dmitry@markin.tech> Co-authored-by:
Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
parent
a4791617
Showing
- prdoc/pr_6016.prdoc 15 additions, 0 deletionsprdoc/pr_6016.prdoc
- substrate/client/network/src/litep2p/shim/notification/peerset.rs 154 additions, 146 deletions...e/client/network/src/litep2p/shim/notification/peerset.rs
- substrate/client/network/src/litep2p/shim/notification/tests/peerset.rs 245 additions, 11 deletions...nt/network/src/litep2p/shim/notification/tests/peerset.rs
Please register or sign in to comment