Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 0a76d86

Browse files
jbenetStebalien
authored andcommitted
added stats bw and swarm peers
1 parent 8aec843 commit 0a76d86

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

shell.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
ma "github.com/multiformats/go-multiaddr"
2121
manet "github.com/multiformats/go-multiaddr-net"
2222
tar "github.com/whyrusleeping/tar-utils"
23+
24+
p2pmetrics "gx/ipfs/QmdeBtQGXjSt7cb97nx9JyLHHv5va2LyEAue7Q5tDFzpLy/go-libp2p-metrics"
2325
)
2426

2527
const (
@@ -850,3 +852,34 @@ func (s *Shell) ObjectStat(key string) (*ObjectStats, error) {
850852

851853
return stat, nil
852854
}
855+
856+
// ObjectStat gets stats for the DAG object named by key. It returns
857+
// the stats of the requested Object or an error.
858+
func (s *Shell) StatsBW() (*p2pmetrics.Stats, error) {
859+
v := &p2pmetrics.Stats{}
860+
err := s.RequestDecode(context.TODO(), &v, "stats/bw")
861+
return v, err
862+
}
863+
864+
type SwarmStreamInfo struct {
865+
Protocol string
866+
}
867+
868+
type SwarmConnInfo struct {
869+
Addr string
870+
Peer string
871+
Latency string
872+
Muxer string
873+
Streams []SwarmStreamInfo
874+
}
875+
876+
type SwarmConnInfos struct {
877+
Peers []SwarmConnInfo
878+
}
879+
880+
// SwarmPeers gets all the swarm peers
881+
func (s *Shell) SwarmPeers() (*SwarmConnInfos, error) {
882+
v := &SwarmConnInfos{}
883+
err := s.RequestDecode(context.TODO(), &v, "swarm/peers")
884+
return v, err
885+
}

0 commit comments

Comments
 (0)