Skip to content

Commit

Permalink
go/extra/stats: add block singature counting tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Dec 23, 2019
1 parent fbed77b commit cff4b6e
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/2500.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entity block signatures count tool.
2 changes: 1 addition & 1 deletion go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all: build

# Build.
# List of Go binaries to build.
go-binaries := oasis-node oasis-test-runner oasis-net-runner
go-binaries := oasis-node oasis-test-runner oasis-net-runner extra/stats
# List of test helpers to build.
test-helpers := urkel
# List of test vectors to generate.
Expand Down
1 change: 1 addition & 0 deletions go/extra/stats/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extra/stats
19 changes: 19 additions & 0 deletions go/extra/stats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Stats

Queries a node for networks stats. Currently implemented per entity block
signature counts.

## Usage

```
extra/stats entity-signatures \
--address unix:<node_dir>/internal.sock \
--start-block 0 \
--end-block 100 \
--top-n 100
|Rank |Entity ID |Nodes |Signatures|
------------------------------------------------------------------------------------------
|1 |ef9ccfc825d5f0087e56937c697b46520f29f81e21d8a289218a4ebaef00509c| 6| 100|
|2 |4ea5328f943ef6f66daaed74cb0e99c3b1c45f76307b425003dbc7cb3638ed35| 1| 80|
...
53 changes: 53 additions & 0 deletions go/extra/stats/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Package cmd implements stats cmd tool.
package cmd

import (
"fmt"

"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"

"github.com/oasislabs/oasis-core/go/common/logging"
"github.com/oasislabs/oasis-core/go/common/version"
"github.com/oasislabs/oasis-core/go/oasis-node/cmd/common"
)

const cfgLogLevel = "log.level"

var (
rootCmd = &cobra.Command{
Use: "stats",
Short: "Oasis stats",
Version: version.SoftwareVersion,
}

rootFlags = flag.NewFlagSet("", flag.ContinueOnError)
)

// RootCommand returns the root (top level) cobra.Command.
func RootCommand() *cobra.Command {
return rootCmd
}

// Execute spawns the main entry point after handling the command line arguments.
func Execute() {
var logLevel logging.Level
if err := logLevel.Set(viper.GetString(cfgLogLevel)); err != nil {
common.EarlyLogAndExit(fmt.Errorf("root: failed to set log level: %w", err))
}

if err := rootCmd.Execute(); err != nil {
common.EarlyLogAndExit(err)
}
}

func init() {
logLevel := logging.LevelInfo
rootFlags.Var(&logLevel, cfgLogLevel, "log level")
_ = viper.BindPFlags(rootFlags)
rootCmd.PersistentFlags().AddFlagSet(rootFlags)

// Register all of the sub-commands.
RegisterStatsCmd(rootCmd)
}
Loading

0 comments on commit cff4b6e

Please sign in to comment.