Skip to content

Commit 5b193c0

Browse files
studystillenvestccCoderZhi
authored
refactor: use the built-in max/min to simplify the code (#4632)
Signed-off-by: studystill <chenghuiyue@outlook.com> Co-authored-by: Chen Chen <chen1233216@hotmail.com> Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
1 parent 21c7b2d commit 5b193c0

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

actsync/actionsync.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ func (as *ActionSync) selectPeers() ([]peer.AddrInfo, error) {
191191
if err != nil {
192192
return nil, err
193193
}
194-
repeat := batchPeerSize
195-
if repeat > len(neighbors) {
196-
repeat = len(neighbors)
197-
}
194+
repeat := min(batchPeerSize, len(neighbors))
198195
if repeat == 0 {
199196
return nil, errors.New("no peers")
200197
}

0 commit comments

Comments
 (0)