message.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. package dashboard
  17. import (
  18. "encoding/json"
  19. "github.com/ethereum/go-ethereum/common"
  20. )
  21. type Message struct {
  22. General *GeneralMessage `json:"general,omitempty"`
  23. Home *HomeMessage `json:"home,omitempty"`
  24. Chain *ChainMessage `json:"chain,omitempty"`
  25. TxPool *TxPoolMessage `json:"txpool,omitempty"`
  26. Network *NetworkMessage `json:"network,omitempty"`
  27. System *SystemMessage `json:"system,omitempty"`
  28. Logs *LogsMessage `json:"logs,omitempty"`
  29. }
  30. type ChartEntries []*ChartEntry
  31. type ChartEntry struct {
  32. Value float64 `json:"value"`
  33. }
  34. type GeneralMessage struct {
  35. Version string `json:"version,omitempty"`
  36. Commit string `json:"commit,omitempty"`
  37. Genesis common.Hash `json:"genesis,omitempty"`
  38. }
  39. type HomeMessage struct {
  40. /* TODO (kurkomisi) */
  41. }
  42. type ChainMessage struct {
  43. CurrentBlock *block `json:"currentBlock,omitempty"`
  44. }
  45. type TxPoolMessage struct {
  46. /* TODO (kurkomisi) */
  47. }
  48. // NetworkMessage contains information about the peers
  49. // organized based on their IP address and node ID.
  50. type NetworkMessage struct {
  51. Peers *peerContainer `json:"peers,omitempty"` // Peer tree.
  52. Diff []*peerEvent `json:"diff,omitempty"` // Events that change the peer tree.
  53. }
  54. // SystemMessage contains the metered system data samples.
  55. type SystemMessage struct {
  56. ActiveMemory ChartEntries `json:"activeMemory,omitempty"`
  57. VirtualMemory ChartEntries `json:"virtualMemory,omitempty"`
  58. NetworkIngress ChartEntries `json:"networkIngress,omitempty"`
  59. NetworkEgress ChartEntries `json:"networkEgress,omitempty"`
  60. ProcessCPU ChartEntries `json:"processCPU,omitempty"`
  61. SystemCPU ChartEntries `json:"systemCPU,omitempty"`
  62. DiskRead ChartEntries `json:"diskRead,omitempty"`
  63. DiskWrite ChartEntries `json:"diskWrite,omitempty"`
  64. }
  65. // LogsMessage wraps up a log chunk. If 'Source' isn't present, the chunk is a stream chunk.
  66. type LogsMessage struct {
  67. Source *LogFile `json:"source,omitempty"` // Attributes of the log file.
  68. Chunk json.RawMessage `json:"chunk"` // Contains log records.
  69. }
  70. // LogFile contains the attributes of a log file.
  71. type LogFile struct {
  72. Name string `json:"name"` // The name of the file.
  73. Last bool `json:"last"` // Denotes if the actual log file is the last one in the directory.
  74. }
  75. // Request represents the client request.
  76. type Request struct {
  77. Logs *LogsRequest `json:"logs,omitempty"`
  78. }
  79. // LogsRequest contains the attributes of the log file the client wants to receive.
  80. type LogsRequest struct {
  81. Name string `json:"name"` // The request handler searches for log file based on this file name.
  82. Past bool `json:"past"` // Denotes whether the client wants the previous or the next file.
  83. }