Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/cmds: hide peers info default in bitswap stat #5820

Merged
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
16 changes: 14 additions & 2 deletions core/commands/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,18 @@ Print out all blocks currently on the bitswap wantlist for the local peer.`,
},
}

const (
bitswapVerboseOptionName = "verbose"
)

var bitswapStatCmd = &cmds.Command{
Helptext: cmdkit.HelpText{
Tagline: "Show some diagnostic information on the bitswap agent.",
ShortDescription: ``,
},
Options: []cmdkit.Option{
cmdkit.BoolOption(bitswapVerboseOptionName, "v", "Print extra information"),
},
Type: bitswap.Stat{},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
nd, err := cmdenv.GetNode(env)
Expand Down Expand Up @@ -122,6 +129,8 @@ var bitswapStatCmd = &cmds.Command{
if err != nil {
return err
}
verbose, _ := req.Options[bitswapVerboseOptionName].(bool)

fmt.Fprintln(w, "bitswap status")
fmt.Fprintf(w, "\tprovides buffer: %d / %d\n", s.ProvideBufLen, bitswap.HasBlockBufferSize)
fmt.Fprintf(w, "\tblocks received: %d\n", s.BlocksReceived)
Expand All @@ -134,9 +143,12 @@ var bitswapStatCmd = &cmds.Command{
for _, k := range s.Wantlist {
fmt.Fprintf(w, "\t\t%s\n", enc.Encode(k))
}

fmt.Fprintf(w, "\tpartners [%d]\n", len(s.Peers))
for _, p := range s.Peers {
fmt.Fprintf(w, "\t\t%s\n", p)
if verbose {
for _, p := range s.Peers {
fmt.Fprintf(w, "\t\t%s\n", p)
}
}

return nil
Expand Down