dashboard

package
v1.8.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2018 License: GPL-3.0 Imports: 27 Imported by: 0

README

Go Ethereum Dashboard

The dashboard is a data visualizer integrated into geth, intended to collect and visualize useful information of an Ethereum node. It consists of two parts:

  • The client visualizes the collected data.
  • The server collects the data, and updates the clients.

The client's UI uses React with JSX syntax, which is validated by the ESLint linter mostly according to the Airbnb React/JSX Style Guide. The style is defined in the .eslintrc configuration file. The resources are bundled into a single bundle.js file using Webpack, which relies on the webpack.config.js. The bundled file is referenced from dashboard.html and takes part in the assets.go too. The necessary dependencies for the module bundler are gathered by Node.js.

Development and bundling

As the dashboard depends on certain NPM packages (which are not included in the go-ethereum repo), these need to be installed first:

$ (cd dashboard/assets && yarn install && yarn flow)

Normally the dashboard assets are bundled into Geth via go-bindata to avoid external dependencies. Rebuilding Geth after each UI modification however is not feasible from a developer perspective. Instead, we can run yarn dev to watch for file system changes and refresh the browser automatically.

$ geth --dashboard --vmodule=dashboard=5
$ (cd dashboard/assets && yarn dev)

To bundle up the final UI into Geth, run go generate:

$ (cd dashboard && go generate)

Static type checking

Since JavaScript doesn't provide type safety, Flow is used to check types. These are only useful during development, so at the end of the process Babel will strip them.

To take advantage of static type checking, your IDE needs to be prepared for it. In case of Atom a configuration guide can be found here: Install the Nuclide package for Flow support, making sure it installs all of its support packages by enabling Install Recommended Packages on Startup, and set the path of the flow-bin which were installed previously by yarn.

For more IDE support install the linter-eslint package too, which finds the .eslintrc file, and provides real-time linting. Atom warns, that these two packages are incompatible, but they seem to work well together. For third-party library errors and auto-completion flow-typed is used.

Have fun

Webpack offers handy tools for visualizing the bundle's dependency tree and space usage.

  • Generate the bundle's profile running yarn stats
  • For the dependency tree go to Webpack Analyze, and import stats.json
  • For the space usage go to Webpack Visualizer, and import stats.json

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Host:    "localhost",
	Port:    8080,
	Refresh: 5 * time.Second,
}

DefaultConfig contains default settings for the dashboard.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest added in v1.8.0

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString added in v1.8.0

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Digests added in v1.8.0

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString added in v1.8.0

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

Types

type ChainMessage added in v1.8.0

type ChainMessage struct {
}

type ChartEntries added in v1.8.0

type ChartEntries []*ChartEntry

type ChartEntry added in v1.8.0

type ChartEntry struct {
	Time  time.Time `json:"time,omitempty"`
	Value float64   `json:"value,omitempty"`
}

type Config

type Config struct {
	// Host is the host interface on which to start the dashboard server. If this
	// field is empty, no dashboard will be started.
	Host string `toml:",omitempty"`

	// Port is the TCP port number on which to start the dashboard server. The
	// default zero value is/ valid and will pick a port number randomly (useful
	// for ephemeral nodes).
	Port int `toml:",omitempty"`

	// Refresh is the refresh rate of the data updates, the chartEntry will be collected this often.
	Refresh time.Duration `toml:",omitempty"`
}

Config contains the configuration parameters of the dashboard.

type Dashboard

type Dashboard struct {
	// contains filtered or unexported fields
}

Dashboard contains the dashboard internals.

func New

func New(config *Config, commit string, logdir string) *Dashboard

New creates a new dashboard instance with the given configuration.

func (*Dashboard) APIs

func (db *Dashboard) APIs() []rpc.API

APIs implements the node.Service interface.

func (*Dashboard) Protocols

func (db *Dashboard) Protocols() []p2p.Protocol

Protocols implements the node.Service interface.

func (*Dashboard) Start

func (db *Dashboard) Start(server *p2p.Server) error

Start starts the data collection thread and the listening server of the dashboard. Implements the node.Service interface.

func (*Dashboard) Stop

func (db *Dashboard) Stop() error

Stop stops the data collection thread and the connection listener of the dashboard. Implements the node.Service interface.

type GeneralMessage added in v1.8.0

type GeneralMessage struct {
	Version string `json:"version,omitempty"`
	Commit  string `json:"commit,omitempty"`
}

type HomeMessage added in v1.8.0

type HomeMessage struct {
}

type LogFile added in v1.8.13

type LogFile struct {
	Name string `json:"name"` // The name of the file.
	Last bool   `json:"last"` // Denotes if the actual log file is the last one in the directory.
}

LogFile contains the attributes of a log file.

type LogsMessage added in v1.8.0

type LogsMessage struct {
	Source *LogFile        `json:"source,omitempty"` // Attributes of the log file.
	Chunk  json.RawMessage `json:"chunk"`            // Contains log records.
}

LogsMessage wraps up a log chunk. If Source isn't present, the chunk is a stream chunk.

type LogsRequest added in v1.8.13

type LogsRequest struct {
	Name string `json:"name"` // The request handler searches for log file based on this file name.
	Past bool   `json:"past"` // Denotes whether the client wants the previous or the next file.
}

type Message added in v1.8.0

type Message struct {
	General *GeneralMessage `json:"general,omitempty"`
	Home    *HomeMessage    `json:"home,omitempty"`
	Chain   *ChainMessage   `json:"chain,omitempty"`
	TxPool  *TxPoolMessage  `json:"txpool,omitempty"`
	Network *NetworkMessage `json:"network,omitempty"`
	System  *SystemMessage  `json:"system,omitempty"`
	Logs    *LogsMessage    `json:"logs,omitempty"`
}

type NetworkMessage added in v1.8.0

type NetworkMessage struct {
}

type Request added in v1.8.13

type Request struct {
	Logs *LogsRequest `json:"logs,omitempty"`
}

Request represents the client request.

type SystemMessage added in v1.8.0

type SystemMessage struct {
	ActiveMemory   ChartEntries `json:"activeMemory,omitempty"`
	VirtualMemory  ChartEntries `json:"virtualMemory,omitempty"`
	NetworkIngress ChartEntries `json:"networkIngress,omitempty"`
	NetworkEgress  ChartEntries `json:"networkEgress,omitempty"`
	ProcessCPU     ChartEntries `json:"processCPU,omitempty"`
	SystemCPU      ChartEntries `json:"systemCPU,omitempty"`
	DiskRead       ChartEntries `json:"diskRead,omitempty"`
	DiskWrite      ChartEntries `json:"diskWrite,omitempty"`
}

type TxPoolMessage added in v1.8.0

type TxPoolMessage struct {
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL