Skip to content

Commit 902ec82

Browse files
authored
dkg: use slices.Contains to simplify code (#4201)
There is a [new function](https://pkg.go.dev/[email protected]#Contains) added in the go1.21 standard library, which can make the code more concise and easy to read. category: refactor ticket: none
1 parent b844787 commit 902ec82

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

dkg/pedersen/reshare.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ func RunReshareDKG(ctx context.Context, config *Config, board *Board, shares []s
2929

3030
// Validate that AddedPeers and RemovedPeers are disjoint sets
3131
for _, addedPeer := range config.Reshare.AddedPeers {
32-
for _, removedPeer := range config.Reshare.RemovedPeers {
33-
if addedPeer == removedPeer {
34-
return nil, errors.New("peer cannot be both added and removed", z.Any("peer_id", addedPeer))
35-
}
32+
if slices.Contains(config.Reshare.RemovedPeers, addedPeer) {
33+
return nil, errors.New("peer cannot be both added and removed", z.Any("peer_id", addedPeer))
3634
}
3735
}
3836

0 commit comments

Comments
 (0)