diff options
author | Kurkó Mihály <kurkomisi@users.noreply.github.com> | 2017-11-15 01:34:00 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-11-15 01:34:00 +0800 |
commit | ba62215d9ef8655743ce7b1380056755943e3d72 (patch) | |
tree | ca74e2d737759f44930469f5c285443efe5f99cc /cmd | |
parent | 984c25ac406e86255b289a3d7fec4cd91a17707f (diff) | |
download | go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.tar go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.tar.gz go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.tar.bz2 go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.tar.lz go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.tar.xz go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.tar.zst go-tangerine-ba62215d9ef8655743ce7b1380056755943e3d72.zip |
cmd, dashboard: dashboard using React, Material-UI, Recharts (#15393)
* cmd, dashboard: dashboard using React, Material-UI, Recharts
* cmd, dashboard, metrics: initial proof of concept dashboard
* dashboard: delete blobs
* dashboard: gofmt -s -w .
* dashboard: minor text and code polishes
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/geth/config.go | 21 | ||||
-rw-r--r-- | cmd/geth/main.go | 5 | ||||
-rw-r--r-- | cmd/geth/usage.go | 14 | ||||
-rw-r--r-- | cmd/utils/flags.go | 41 |
4 files changed, 74 insertions, 7 deletions
diff --git a/cmd/geth/config.go b/cmd/geth/config.go index d55a5e08d..27490c404 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/contracts/release" + "github.com/ethereum/go-ethereum/dashboard" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" @@ -76,10 +77,11 @@ type ethstatsConfig struct { } type gethConfig struct { - Eth eth.Config - Shh whisper.Config - Node node.Config - Ethstats ethstatsConfig + Eth eth.Config + Shh whisper.Config + Node node.Config + Ethstats ethstatsConfig + Dashboard dashboard.Config } func loadConfig(file string, cfg *gethConfig) error { @@ -110,9 +112,10 @@ func defaultNodeConfig() node.Config { func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { // Load defaults. cfg := gethConfig{ - Eth: eth.DefaultConfig, - Shh: whisper.DefaultConfig, - Node: defaultNodeConfig(), + Eth: eth.DefaultConfig, + Shh: whisper.DefaultConfig, + Node: defaultNodeConfig(), + Dashboard: dashboard.DefaultConfig, } // Load config file. @@ -134,6 +137,7 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) { } utils.SetShhConfig(ctx, stack, &cfg.Shh) + utils.SetDashboardConfig(ctx, &cfg.Dashboard) return stack, cfg } @@ -153,6 +157,9 @@ func makeFullNode(ctx *cli.Context) *node.Node { utils.RegisterEthService(stack, &cfg.Eth) + if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) { + utils.RegisterDashboardService(stack, &cfg.Dashboard) + } // Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode shhEnabled := enableWhisper(ctx) shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DeveloperFlag.Name) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 8bd27b5c6..bdb7fad62 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -61,6 +61,11 @@ var ( utils.DataDirFlag, utils.KeyStoreDirFlag, utils.NoUSBFlag, + utils.DashboardEnabledFlag, + utils.DashboardAddrFlag, + utils.DashboardPortFlag, + utils.DashboardRefreshFlag, + utils.DashboardAssetsFlag, utils.EthashCacheDirFlag, utils.EthashCachesInMemoryFlag, utils.EthashCachesOnDiskFlag, diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 5bb2255f3..a834d5b7a 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/internal/debug" "gopkg.in/urfave/cli.v1" + "strings" ) // AppHelpTemplate is the test template for the default, global app help topic. @@ -97,6 +98,16 @@ var AppHelpFlagGroups = []flagGroup{ utils.EthashDatasetsOnDiskFlag, }, }, + //{ + // Name: "DASHBOARD", + // Flags: []cli.Flag{ + // utils.DashboardEnabledFlag, + // utils.DashboardAddrFlag, + // utils.DashboardPortFlag, + // utils.DashboardRefreshFlag, + // utils.DashboardAssetsFlag, + // }, + //}, { Name: "TRANSACTION POOL", Flags: []cli.Flag{ @@ -268,6 +279,9 @@ func init() { uncategorized := []cli.Flag{} for _, flag := range data.(*cli.App).Flags { if _, ok := categorized[flag.String()]; !ok { + if strings.HasPrefix(flag.GetName(), "dashboard") { + continue + } uncategorized = append(uncategorized, flag) } } diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a996b9d0a..5c2929268 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -38,6 +38,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/dashboard" "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/gasprice" @@ -183,6 +184,31 @@ var ( Name: "lightkdf", Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", } + // Dashboard settings + DashboardEnabledFlag = cli.BoolFlag{ + Name: "dashboard", + Usage: "Enable the dashboard", + } + DashboardAddrFlag = cli.StringFlag{ + Name: "dashboard.addr", + Usage: "Dashboard listening interface", + Value: dashboard.DefaultConfig.Host, + } + DashboardPortFlag = cli.IntFlag{ + Name: "dashboard.host", + Usage: "Dashboard listening port", + Value: dashboard.DefaultConfig.Port, + } + DashboardRefreshFlag = cli.DurationFlag{ + Name: "dashboard.refresh", + Usage: "Dashboard metrics collection refresh rate", + Value: dashboard.DefaultConfig.Refresh, + } + DashboardAssetsFlag = cli.StringFlag{ + Name: "dashboard.assets", + Usage: "Developer flag to serve the dashboard from the local file system", + Value: dashboard.DefaultConfig.Assets, + } // Ethash settings EthashCacheDirFlag = DirectoryFlag{ Name: "ethash.cachedir", @@ -1019,6 +1045,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { } } +// SetDashboardConfig applies dashboard related command line flags to the config. +func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) { + cfg.Host = ctx.GlobalString(DashboardAddrFlag.Name) + cfg.Port = ctx.GlobalInt(DashboardPortFlag.Name) + cfg.Refresh = ctx.GlobalDuration(DashboardRefreshFlag.Name) + cfg.Assets = ctx.GlobalString(DashboardAssetsFlag.Name) +} + // RegisterEthService adds an Ethereum client to the stack. func RegisterEthService(stack *node.Node, cfg *eth.Config) { var err error @@ -1041,6 +1075,13 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) { } } +// RegisterDashboardService adds a dashboard to the stack. +func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config) { + stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { + return dashboard.New(cfg) + }) +} + // RegisterShhService configures Whisper and adds it to the given node. func RegisterShhService(stack *node.Node, cfg *whisper.Config) { if err := stack.Register(func(n *node.ServiceContext) (node.Service, error) { |