types.go 8.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
package logger

import (
	"time"
)

type utctime8601 struct{}

func (utctime8601) MarshalJSON() ([]byte, error) {
	// FIX This should be re-formated for proper ISO 8601
	return []byte(`"` + time.Now().UTC().Format(time.RFC3339Nano)[:26] + `Z"`), nil
}

14
type JsonLog interface {
15 16 17
	EventName() string
}

18 19 20 21 22 23
type LogEvent struct {
	Guid string      `json:"guid"`
	Ts   utctime8601 `json:"ts"`
	// Level string      `json:"level"`
}

24
type LogStarting struct {
25 26 27 28
	ClientString    string `json:"version_string"`
	Coinbase        string `json:"coinbase"`
	ProtocolVersion int    `json:"eth_version"`
	LogEvent
29 30
}

31 32 33 34
func (l *LogStarting) EventName() string {
	return "starting"
}

35
type P2PConnecting struct {
36 37 38 39
	RemoteId       string `json:"remote_id"`
	RemoteEndpoint string `json:"remote_endpoint"`
	NumConnections int    `json:"num_connections"`
	LogEvent
40 41
}

42 43 44 45
func (l *P2PConnecting) EventName() string {
	return "p2p.connecting"
}

46
type P2PConnected struct {
47 48 49
	NumConnections int    `json:"num_connections"`
	RemoteId       string `json:"remote_id"`
	LogEvent
50 51
}

52 53 54 55
func (l *P2PConnected) EventName() string {
	return "p2p.connected"
}

56 57 58 59
type P2PHandshaked struct {
	RemoteCapabilities []string `json:"remote_capabilities"`
	RemoteId           string   `json:"remote_id"`
	NumConnections     int      `json:"num_connections"`
60
	LogEvent
61 62
}

63 64 65 66
func (l *P2PHandshaked) EventName() string {
	return "p2p.handshaked"
}

67
type P2PDisconnected struct {
68 69 70
	NumConnections int    `json:"num_connections"`
	RemoteId       string `json:"remote_id"`
	LogEvent
71 72
}

73 74 75 76
func (l *P2PDisconnected) EventName() string {
	return "p2p.disconnected"
}

77
type P2PDisconnecting struct {
78 79 80 81
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
82 83
}

84 85 86 87
func (l *P2PDisconnecting) EventName() string {
	return "p2p.disconnecting"
}

88
type P2PDisconnectingBadHandshake struct {
89 90 91 92
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
93 94
}

95 96 97 98
func (l *P2PDisconnectingBadHandshake) EventName() string {
	return "p2p.disconnecting.bad_handshake"
}

99
type P2PDisconnectingBadProtocol struct {
100 101 102 103
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
104 105
}

106 107 108 109
func (l *P2PDisconnectingBadProtocol) EventName() string {
	return "p2p.disconnecting.bad_protocol"
}

110
type P2PDisconnectingReputation struct {
111 112 113 114
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
115 116
}

117 118 119 120
func (l *P2PDisconnectingReputation) EventName() string {
	return "p2p.disconnecting.reputation"
}

121
type P2PDisconnectingDHT struct {
122 123 124 125
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
126 127
}

128 129 130 131
func (l *P2PDisconnectingDHT) EventName() string {
	return "p2p.disconnecting.dht"
}

132
type P2PEthDisconnectingBadBlock struct {
133 134 135 136
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
137 138
}

139 140 141 142
func (l *P2PEthDisconnectingBadBlock) EventName() string {
	return "p2p.eth.disconnecting.bad_block"
}

143
type P2PEthDisconnectingBadTx struct {
144 145 146 147
	Reason         string `json:"reason"`
	RemoteId       string `json:"remote_id"`
	NumConnections int    `json:"num_connections"`
	LogEvent
148 149
}

150 151 152 153
func (l *P2PEthDisconnectingBadTx) EventName() string {
	return "p2p.eth.disconnecting.bad_tx"
}

154
type EthNewBlockMined struct {
155 156 157 158 159 160 161
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockHexRlp     string `json:"block_hexrlp"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
162 163
}

164 165 166 167
func (l *EthNewBlockMined) EventName() string {
	return "eth.newblock.mined"
}

168
type EthNewBlockBroadcasted struct {
169 170 171 172 173 174
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
175 176
}

177 178 179 180
func (l *EthNewBlockBroadcasted) EventName() string {
	return "eth.newblock.broadcasted"
}

181
type EthNewBlockReceived struct {
182 183 184 185 186 187
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
188 189
}

190 191 192 193
func (l *EthNewBlockReceived) EventName() string {
	return "eth.newblock.received"
}

194
type EthNewBlockIsKnown struct {
195 196 197 198 199 200
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
201 202
}

203 204 205 206
func (l *EthNewBlockIsKnown) EventName() string {
	return "eth.newblock.is_known"
}

207
type EthNewBlockIsNew struct {
208 209 210 211 212 213
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
214 215
}

216 217 218 219
func (l *EthNewBlockIsNew) EventName() string {
	return "eth.newblock.is_new"
}

220
type EthNewBlockMissingParent struct {
221 222 223 224 225 226
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
227 228
}

229 230 231 232
func (l *EthNewBlockMissingParent) EventName() string {
	return "eth.newblock.missing_parent"
}

233
type EthNewBlockIsInvalid struct {
234 235 236 237 238 239
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
240 241
}

242 243 244 245
func (l *EthNewBlockIsInvalid) EventName() string {
	return "eth.newblock.is_invalid"
}

246
type EthNewBlockChainIsOlder struct {
247 248 249 250 251 252
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
253 254
}

255 256 257 258
func (l *EthNewBlockChainIsOlder) EventName() string {
	return "eth.newblock.chain.is_older"
}

259
type EthNewBlockChainIsCanonical struct {
260 261 262 263 264 265
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
266 267
}

268 269 270 271
func (l *EthNewBlockChainIsCanonical) EventName() string {
	return "eth.newblock.chain.is_cannonical"
}

272
type EthNewBlockChainNotCanonical struct {
273 274 275 276 277 278
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
279 280
}

281 282 283 284
func (l *EthNewBlockChainNotCanonical) EventName() string {
	return "eth.newblock.chain.not_cannonical"
}

285
type EthNewBlockChainSwitched struct {
286 287 288 289 290 291 292
	BlockNumber     int    `json:"block_number"`
	HeadHash        string `json:"head_hash"`
	OldHeadHash     string `json:"old_head_hash"`
	BlockHash       string `json:"block_hash"`
	BlockDifficulty int    `json:"block_difficulty"`
	BlockPrevHash   string `json:"block_prev_hash"`
	LogEvent
293 294
}

295 296 297 298
func (l *EthNewBlockChainSwitched) EventName() string {
	return "eth.newblock.chain.switched"
}

299
type EthTxCreated struct {
300 301 302 303 304 305
	TxHash    string `json:"tx_hash"`
	TxSender  string `json:"tx_sender"`
	TxAddress string `json:"tx_address"`
	TxHexRLP  string `json:"tx_hexrlp"`
	TxNonce   int    `json:"tx_nonce"`
	LogEvent
306 307
}

308 309 310 311
func (l *EthTxCreated) EventName() string {
	return "eth.tx.created"
}

312
type EthTxReceived struct {
313 314 315 316 317 318
	TxHash    string `json:"tx_hash"`
	TxAddress string `json:"tx_address"`
	TxHexRLP  string `json:"tx_hexrlp"`
	RemoteId  string `json:"remote_id"`
	TxNonce   int    `json:"tx_nonce"`
	LogEvent
319 320
}

321 322 323 324
func (l *EthTxReceived) EventName() string {
	return "eth.tx.received"
}

325
type EthTxBroadcasted struct {
326 327 328 329 330
	TxHash    string `json:"tx_hash"`
	TxSender  string `json:"tx_sender"`
	TxAddress string `json:"tx_address"`
	TxNonce   int    `json:"tx_nonce"`
	LogEvent
331 332
}

333 334 335 336
func (l *EthTxBroadcasted) EventName() string {
	return "eth.tx.broadcasted"
}

337
type EthTxValidated struct {
338 339 340 341 342
	TxHash    string `json:"tx_hash"`
	TxSender  string `json:"tx_sender"`
	TxAddress string `json:"tx_address"`
	TxNonce   int    `json:"tx_nonce"`
	LogEvent
343 344
}

345 346 347 348
func (l *EthTxValidated) EventName() string {
	return "eth.tx.validated"
}

349
type EthTxIsInvalid struct {
350 351 352 353 354 355
	TxHash    string `json:"tx_hash"`
	TxSender  string `json:"tx_sender"`
	TxAddress string `json:"tx_address"`
	Reason    string `json:"reason"`
	TxNonce   int    `json:"tx_nonce"`
	LogEvent
356
}
357 358 359 360

func (l *EthTxIsInvalid) EventName() string {
	return "eth.tx.is_invalid"
}