dashboard

package
v0.0.0-...-39cdb81 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 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)

资产加载并返回给定名称的资产。 如果找不到资产或 无法加载。

func AssetDigest

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

assetdigest返回具有给定名称的文件摘要。它返回一个 如果找不到资产或无法加载摘要,则出错。

func AssetDir

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

assetdir返回某个 通过go bindata嵌入到文件中的目录。 例如,如果对数据/运行go bindata。数据包含 以下层次结构: 数据/ 英尺·txt IMG/ A.PNG B.PNG 然后assetdir(“data”)将返回[]字符串“foo.txt”,“img”, assetdir(“data/img”)将返回[]字符串“a.png”、“b.png”, assetdir(“foo.txt”)和assetdir(“notexist”)将返回错误,以及 assetdir(“”)将返回[]字符串“data”。

func AssetInfo

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

asset info加载并返回给定名称的资产信息。 如果找不到资产或 无法加载。

func AssetNames

func AssetNames() []string

assetnames返回资产的名称。

func AssetString

func AssetString(name string) (string, error)

asset string以字符串的形式返回资产内容(而不是以[]字节的形式)。

func Digests

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

Digests返回所有已知文件及其校验和的映射。

func MustAsset

func MustAsset(name string) []byte

mustasset与asset类似,但在asset返回错误时会出现恐慌。 它简化了全局变量的安全初始化。

func MustAssetString

func MustAssetString(name string) string

mustassetstring就像assetstring,但当asset返回 错误。它简化了全局变量的安全初始化。

func RestoreAsset

func RestoreAsset(dir, name string) error

restoreset恢复给定目录下的资产。

func RestoreAssets

func RestoreAssets(dir, name string) error

restoresets递归地还原给定目录下的资产。

Types

type ChainMessage

type ChainMessage struct {
}

type ChartEntries

type ChartEntries []*ChartEntry

type ChartEntry

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

type Config

type Config struct {
	//主机是启动仪表板服务器的主机接口。如果这样
	//field is empty, no dashboard will be started.
	Host string `toml:",omitempty"`

	//端口是启动仪表板服务器的TCP端口号。这个
	//默认的零值是/有效的,将随机选择端口号(有用
	//for ephemeral nodes).
	Port int `toml:",omitempty"`

	//refresh是数据更新的刷新率,通常会收集图表条目。
	Refresh time.Duration `toml:",omitempty"`
}

配置包含仪表板的配置参数。

type Dashboard

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

仪表板包含仪表板内部。

func New

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

新建创建具有给定配置的新仪表板实例。

func (*Dashboard) APIs

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

API实现了node.service接口。

func (*Dashboard) Protocols

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

协议实现了node.service接口。

func (*Dashboard) Start

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

Start启动数据收集线程和仪表板的侦听服务器。 实现node.service接口。

func (*Dashboard) Stop

func (db *Dashboard) Stop() error

stop停止数据收集线程和仪表板的连接侦听器。 实现node.service接口。

type GeneralMessage

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

type HomeMessage

type HomeMessage struct {
}

type LogFile

type LogFile struct {
	Name string `json:"name"` //文件名。
	Last bool   `json:"last"` //指示实际日志文件是否是目录中的最后一个。
}

日志文件包含日志文件的属性。

type LogsMessage

type LogsMessage struct {
	Source *LogFile        `json:"source,omitempty"` //日志文件的属性。
	Chunk  json.RawMessage `json:"chunk"`            //包含日志记录。
}

logsmessage包装了一个日志块。如果源不存在,则块是流块。

type LogsRequest

type LogsRequest struct {
	Name string `json:"name"` //请求处理程序根据此文件名搜索日志文件。
	Past bool   `json:"past"` //指示客户端是要上一个文件还是下一个文件。
}

type Message

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

type NetworkMessage struct {
}

type Request

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

请求表示客户端请求。

type SystemMessage

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

type TxPoolMessage struct {
}

Jump to

Keyboard shortcuts

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