Skip to content

Commit

Permalink
fix: golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Sep 10, 2024
1 parent 7385ba1 commit 6b5676d
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions cmd/celestia-appd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package cmd
// start command flag.

import (
"errors"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -566,37 +565,30 @@ func addCommands(
)
}

// checkBBR checks is bbr is configured to be used as a congestion control algo.
// checkBBR checks if BBR is enabled.
func checkBBR(command *cobra.Command) error {
const (
errorMsg = `
// The BBR congestion control algorithm does not appear to be enabled in this
// system's kernel. This is important for the p2p stack to be performant.
//
// to enable bbr call:
//
warning = `
The BBR (Bottleneck Bandwidth and Round-trip propagation time) congestion control algorithm is not enabled in this system's kernel.
BBR is important for the performance of the p2p stack.
To enable BBR:
sudo modprobe tcp_bbr
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
sudo sysctl -p
//
// and can be verified to be running using
//
Then verify BBR is enabled:
sysctl net.ipv4.tcp_congestion_control
// This might not work for all systems, you might have to search online to
// figure out how to enable bbr for your system.
//
// While this node will get worse performance using something other than bbr,
// If you need to bypass this block use the "--force-no-bbr true" flag.
This node will get worse p2p performance using a different congestion control algorithm.
If you need to bypass this check use the --force-no-bbr flag.
`
)

noBBRErr := errors.New(errorMsg)

forceNoBBR, err := command.Flags().GetBool(FlagForceNoBBR)
if err != nil {
return noBBRErr
return err
}
if forceNoBBR {
return nil
Expand All @@ -605,11 +597,13 @@ sysctl net.ipv4.tcp_congestion_control
cmd := exec.Command("sysctl", "net.ipv4.tcp_congestion_control")
output, err := cmd.Output()
if err != nil {
return fmt.Errorf("%v\nFailed to execute 'sysctl net.ipv4.tcp_congestion_control' %w", errorMsg, err)
fmt.Print(warning)
return fmt.Errorf("failed to execute 'sysctl net.ipv4.tcp_congestion_control' %w", err)
}

if !strings.Contains(string(output), "bbr") {
return noBBRErr
fmt.Print(warning)
return fmt.Errorf("BBR not enabled because output %v does not contain 'bbr'", string(output))
}

return nil
Expand Down

0 comments on commit 6b5676d

Please sign in to comment.