Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/sync/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,11 @@

func getPeers(seeds string, logger log.Logger) []peer.ID {
var peerIDs []peer.ID
sl := strings.Split(seeds, ",")
if len(sl) == 0 {
if seeds == "" {
return peerIDs
}
sl := strings.Split(seeds, ",")
Comment on lines +385 to +388
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using strings.Split can result in empty strings in the slice if there are leading, trailing, or consecutive commas in the seeds string. This can lead to unnecessary error logging. Consider using strings.FieldsFunc to avoid empty strings in the slice.

sl := strings.FieldsFunc(seeds, func(r rune) bool { return r == ',' })


Check warning on line 389 in pkg/sync/sync_service.go

View check run for this annotation

Codecov / codecov/patch

pkg/sync/sync_service.go#L388-L389

Added lines #L388 - L389 were not covered by tests
for _, seed := range sl {
maddr, err := multiaddr.NewMultiaddr(seed)
if err != nil {
Expand Down