Skip to content

Commit

Permalink
lint: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkmc committed Mar 28, 2023
1 parent 2069bfc commit a6e5401
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 7 additions & 3 deletions cmd/boost/provider_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ var libp2pInfoCmd = &cli.Command{
if err != nil {
return fmt.Errorf("getting protocols for peer %s: %w", addrInfo.ID, err)
}
sort.Strings(protos)
protostrs := make([]string, 0, len(protos))
for _, proto := range protos {
protostrs = append(protostrs, string(proto))
}
sort.Strings(protostrs)

agentVersionI, err := n.Host.Peerstore().Get(addrInfo.ID, "AgentVersion")
if err != nil {
Expand All @@ -98,7 +102,7 @@ var libp2pInfoCmd = &cli.Command{
"agent": agentVersion,
"id": addrInfo.ID.String(),
"multiaddrs": addrInfo.Addrs,
"protocols": protos,
"protocols": protostrs,
})
}

Expand All @@ -109,7 +113,7 @@ var libp2pInfoCmd = &cli.Command{
for _, addr := range addrInfo.Addrs {
fmt.Println(" " + addr.String())
}
fmt.Println("Protocols:\n" + " " + strings.Join(protos, "\n "))
fmt.Println("Protocols:\n" + " " + strings.Join(protostrs, "\n "))
return nil
},
}
Expand Down
16 changes: 10 additions & 6 deletions cmd/boostx/stats_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ var statsCmd = &cli.Command{
if err != nil {
return fmt.Errorf("getting protocols for peer %s: %w", addrInfo.ID, err)
}
sort.Strings(protos)
protostrs := make([]string, 0, len(protos))
for _, proto := range protos {
protostrs = append(protostrs, string(proto))
}
sort.Strings(protostrs)

// Get peer's libp2p agent version
agentVersionI, err := n.Host.Peerstore().Get(addrInfo.ID, "AgentVersion")
Expand All @@ -151,7 +155,7 @@ var statsCmd = &cli.Command{

// Get SP's supported transports
var transports *transports_types.QueryResponse
if contains(protos, string(lp2pimpl.TransportsProtocolID)) {
if contains(protostrs, string(lp2pimpl.TransportsProtocolID)) {
client := lp2pimpl.NewTransportsClient(n.Host)
transports, err = client.SendQuery(ctx, addrInfo.ID)
if err != nil {
Expand All @@ -162,7 +166,7 @@ var statsCmd = &cli.Command{
lk.Lock()
var out string
out += "Provider " + maddr.String()
if contains(protos, "/fil/storage/mk/1.2.0") {
if contains(protostrs, "/fil/storage/mk/1.2.0") {
out += " is running boost"

boostNodes++
Expand All @@ -174,15 +178,15 @@ var statsCmd = &cli.Command{
transportProtos[p.Name]++
}
}
} else if contains(protos, "/fil/storage/mk/1.1.0") {
} else if contains(protostrs, "/fil/storage/mk/1.1.0") {
out += " is running markets"
agentVersions[agentVersion]++
marketsNodes++
} else {
out += " is not running markets or boost"
noProtocolsNodes++
}
if contains(protos, "/legs/head/") {
if contains(protostrs, "/legs/head/") {
out += " (with indexer)"
indexerNodes++
}
Expand All @@ -193,7 +197,7 @@ var statsCmd = &cli.Command{
out += " raw power: " + minerToMinerPower[maddr].RawBytePower.String() + "\n"
out += " quality adj power: " + minerToMinerPower[maddr].QualityAdjPower.String() + "\n"
out += " protocols:\n"
out += " " + strings.Join(protos, "\n ") + "\n"
out += " " + strings.Join(protostrs, "\n ") + "\n"

if transports != nil {
out += " transports:\n"
Expand Down

0 comments on commit a6e5401

Please sign in to comment.