ChainSafe / ChainSafe/gossamer
Implement `AddPeersToReservedSet` and `RemovePeersFromReservedSet` on translation shim type.
- Dominant language
- Go
- Stars
- 454
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
## Issue summary
from design doc:
> `SetReservedPeers`, `AddPeersToReservedSet`, and `RemovePeersFromReservedSet` are all methods to modify the reserved set of peers specific to a protocol. This will definitely be needed for the Parachains initiative. `AddPeersToReservedSet` and `RemovedPeersFromReservedSet` are called by `AddSetReserved` and `RemoveSetReserved` which are just helper functions to add one or remove one peer. These two helper methods are called in the GRANDPA integration. Our current peerset `Handler` exposes a `AddReservedPeer` and `RemoveReservedPeer` but takes a `int` param for `setID`. We will need to translate the `ProtocolName` type using a mapping to `int`. The integer `setID` is enumerated based on the order it is added as a supported notification protocol (see [code](https://github.com/paritytech/polkadot-sdk/blob/3ff1b1db36260cbc47297ab753e2dcec1f5999fd/substrate/client/network/src/service.rs#L395)).
## Implementation details
- Introduce mapping of `ProtocolName` to `int` set ID in translation shim type.
- Implement `AddPeersToReservedSet` and `RemovePeersFromReserveSet` in translation shim type, by utilizing protocol name to set id mapping, and calling `Handler.AddReservedPeer` and `Handler.RemoveReservedPeer` respectively.
## Other information and links
-
## Acceptance criteria
[] 70% code coverage on implemented functions
[] Able to add and remove from reserved set using `ProtocolName` as set.
Contributor guide
Assessment
This issue has not been assessed yet.