github.com/googgoog/go-ethereum@v1.9.7/dashboard/message.go (about)

     1  // Copyright 2017 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package dashboard
    18  
    19  import (
    20  	"encoding/json"
    21  )
    22  
    23  type Message struct {
    24  	General *GeneralMessage `json:"general,omitempty"`
    25  	Home    *HomeMessage    `json:"home,omitempty"`
    26  	Chain   *ChainMessage   `json:"chain,omitempty"`
    27  	TxPool  *TxPoolMessage  `json:"txpool,omitempty"`
    28  	Network *NetworkMessage `json:"network,omitempty"`
    29  	System  *SystemMessage  `json:"system,omitempty"`
    30  	Logs    *LogsMessage    `json:"logs,omitempty"`
    31  }
    32  
    33  type ChartEntries []*ChartEntry
    34  
    35  type ChartEntry struct {
    36  	Value float64 `json:"value"`
    37  }
    38  
    39  type GeneralMessage struct {
    40  	Version string `json:"version,omitempty"`
    41  	Commit  string `json:"commit,omitempty"`
    42  }
    43  
    44  type HomeMessage struct {
    45  	/* TODO (kurkomisi) */
    46  }
    47  
    48  type ChainMessage struct {
    49  	/* TODO (kurkomisi) */
    50  }
    51  
    52  type TxPoolMessage struct {
    53  	/* TODO (kurkomisi) */
    54  }
    55  
    56  // NetworkMessage contains information about the peers
    57  // organized based on their IP address and node ID.
    58  type NetworkMessage struct {
    59  	Peers *peerContainer `json:"peers,omitempty"` // Peer tree.
    60  	Diff  []*peerEvent   `json:"diff,omitempty"`  // Events that change the peer tree.
    61  }
    62  
    63  // SystemMessage contains the metered system data samples.
    64  type SystemMessage struct {
    65  	ActiveMemory   ChartEntries `json:"activeMemory,omitempty"`
    66  	VirtualMemory  ChartEntries `json:"virtualMemory,omitempty"`
    67  	NetworkIngress ChartEntries `json:"networkIngress,omitempty"`
    68  	NetworkEgress  ChartEntries `json:"networkEgress,omitempty"`
    69  	ProcessCPU     ChartEntries `json:"processCPU,omitempty"`
    70  	SystemCPU      ChartEntries `json:"systemCPU,omitempty"`
    71  	DiskRead       ChartEntries `json:"diskRead,omitempty"`
    72  	DiskWrite      ChartEntries `json:"diskWrite,omitempty"`
    73  }
    74  
    75  // LogsMessage wraps up a log chunk. If 'Source' isn't present, the chunk is a stream chunk.
    76  type LogsMessage struct {
    77  	Source *LogFile        `json:"source,omitempty"` // Attributes of the log file.
    78  	Chunk  json.RawMessage `json:"chunk"`            // Contains log records.
    79  }
    80  
    81  // LogFile contains the attributes of a log file.
    82  type LogFile struct {
    83  	Name string `json:"name"` // The name of the file.
    84  	Last bool   `json:"last"` // Denotes if the actual log file is the last one in the directory.
    85  }
    86  
    87  // Request represents the client request.
    88  type Request struct {
    89  	Logs *LogsRequest `json:"logs,omitempty"`
    90  }
    91  
    92  // LogsRequest contains the attributes of the log file the client wants to receive.
    93  type LogsRequest struct {
    94  	Name string `json:"name"` // The request handler searches for log file based on this file name.
    95  	Past bool   `json:"past"` // Denotes whether the client wants the previous or the next file.
    96  }