diff options
Diffstat (limited to 'logger')
-rw-r--r-- | logger/example_test.go | 21 | ||||
-rw-r--r-- | logger/log.go | 39 | ||||
-rw-r--r-- | logger/loggers.go | 134 | ||||
-rw-r--r-- | logger/loggers_test.go | 174 | ||||
-rw-r--r-- | logger/logsystem.go | 63 | ||||
-rw-r--r-- | logger/sys.go | 112 | ||||
-rw-r--r-- | logger/types.go | 359 |
7 files changed, 902 insertions, 0 deletions
diff --git a/logger/example_test.go b/logger/example_test.go new file mode 100644 index 000000000..c624252b8 --- /dev/null +++ b/logger/example_test.go @@ -0,0 +1,21 @@ +package logger + +import "os" + +func ExampleLogger() { + logger := NewLogger("TAG") + logger.Infoln("so awesome") // prints [TAG] so awesome + logger.Infof("this %q is raw", "coin") // prints [TAG] this "coin" is raw +} + +func ExampleLogSystem() { + filename := "test.log" + file, _ := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, os.ModePerm) + fileLog := NewStdLogSystem(file, 0, WarnLevel) + AddLogSystem(fileLog) + + stdoutLog := NewStdLogSystem(os.Stdout, 0, WarnLevel) + AddLogSystem(stdoutLog) + + NewLogger("TAG").Warnln("reactor meltdown") // writes to both logs +} diff --git a/logger/log.go b/logger/log.go new file mode 100644 index 000000000..baa3dfaf2 --- /dev/null +++ b/logger/log.go @@ -0,0 +1,39 @@ +package logger + +import ( + "fmt" + "io" + "log" + "os" + + "github.com/ethereum/go-ethereum/ethutil" +) + +func openLogFile(datadir string, filename string) *os.File { + path := ethutil.AbsolutePath(datadir, filename) + file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + panic(fmt.Sprintf("error opening log file '%s': %v", filename, err)) + } + return file +} + +func New(datadir string, logFile string, logLevel int, logFormat string) LogSystem { + var writer io.Writer + if logFile == "" { + writer = os.Stdout + } else { + writer = openLogFile(datadir, logFile) + } + + var sys LogSystem + switch logFormat { + case "raw": + sys = NewRawLogSystem(writer, 0, LogLevel(logLevel)) + default: + sys = NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel)) + } + AddLogSystem(sys) + + return sys +} diff --git a/logger/loggers.go b/logger/loggers.go new file mode 100644 index 000000000..25263853a --- /dev/null +++ b/logger/loggers.go @@ -0,0 +1,134 @@ +/* +Package logger implements a multi-output leveled logger. + +Other packages use tagged logger to send log messages to shared +(process-wide) logging engine. The shared logging engine dispatches to +multiple log systems. The log level can be set separately per log +system. + +Logging is asynchronous and does not block the caller. Message +formatting is performed by the caller goroutine to avoid incorrect +logging of mutable state. +*/ +package logger + +import ( + "encoding/json" + "fmt" + "os" +) + +type LogLevel uint32 + +const ( + // Standard log levels + Silence LogLevel = iota + ErrorLevel + WarnLevel + InfoLevel + DebugLevel + DebugDetailLevel + JsonLevel = 1000 +) + +// A Logger prints messages prefixed by a given tag. It provides named +// Printf and Println style methods for all loglevels. Each ethereum +// component should have its own logger with a unique prefix. +type Logger struct { + tag string +} + +func NewLogger(tag string) *Logger { + return &Logger{"[" + tag + "] "} +} + +func (logger *Logger) Sendln(level LogLevel, v ...interface{}) { + logMessageC <- message{level, logger.tag + fmt.Sprintln(v...)} +} + +func (logger *Logger) Sendf(level LogLevel, format string, v ...interface{}) { + logMessageC <- message{level, logger.tag + fmt.Sprintf(format, v...)} +} + +// Errorln writes a message with ErrorLevel. +func (logger *Logger) Errorln(v ...interface{}) { + logger.Sendln(ErrorLevel, v...) +} + +// Warnln writes a message with WarnLevel. +func (logger *Logger) Warnln(v ...interface{}) { + logger.Sendln(WarnLevel, v...) +} + +// Infoln writes a message with InfoLevel. +func (logger *Logger) Infoln(v ...interface{}) { + logger.Sendln(InfoLevel, v...) +} + +// Debugln writes a message with DebugLevel. +func (logger *Logger) Debugln(v ...interface{}) { + logger.Sendln(DebugLevel, v...) +} + +// DebugDetailln writes a message with DebugDetailLevel. +func (logger *Logger) DebugDetailln(v ...interface{}) { + logger.Sendln(DebugDetailLevel, v...) +} + +// Errorf writes a message with ErrorLevel. +func (logger *Logger) Errorf(format string, v ...interface{}) { + logger.Sendf(ErrorLevel, format, v...) +} + +// Warnf writes a message with WarnLevel. +func (logger *Logger) Warnf(format string, v ...interface{}) { + logger.Sendf(WarnLevel, format, v...) +} + +// Infof writes a message with InfoLevel. +func (logger *Logger) Infof(format string, v ...interface{}) { + logger.Sendf(InfoLevel, format, v...) +} + +// Debugf writes a message with DebugLevel. +func (logger *Logger) Debugf(format string, v ...interface{}) { + logger.Sendf(DebugLevel, format, v...) +} + +// DebugDetailf writes a message with DebugDetailLevel. +func (logger *Logger) DebugDetailf(format string, v ...interface{}) { + logger.Sendf(DebugDetailLevel, format, v...) +} + +// Fatalln writes a message with ErrorLevel and exits the program. +func (logger *Logger) Fatalln(v ...interface{}) { + logger.Sendln(ErrorLevel, v...) + Flush() + os.Exit(0) +} + +// Fatalf writes a message with ErrorLevel and exits the program. +func (logger *Logger) Fatalf(format string, v ...interface{}) { + logger.Sendf(ErrorLevel, format, v...) + Flush() + os.Exit(0) +} + +type JsonLogger struct { + Coinbase string +} + +func NewJsonLogger() *JsonLogger { + return &JsonLogger{} +} + +func (logger *JsonLogger) LogJson(v JsonLog) { + msgname := v.EventName() + obj := map[string]interface{}{ + msgname: v, + } + + jsontxt, _ := json.Marshal(obj) + logMessageC <- message{JsonLevel, string(jsontxt)} + +} diff --git a/logger/loggers_test.go b/logger/loggers_test.go new file mode 100644 index 000000000..adc4df016 --- /dev/null +++ b/logger/loggers_test.go @@ -0,0 +1,174 @@ +package logger + +import ( + "io/ioutil" + "math/rand" + "os" + "sync" + "testing" + "time" +) + +type TestLogSystem struct { + mutex sync.Mutex + output string + level LogLevel +} + +func (ls *TestLogSystem) LogPrint(level LogLevel, msg string) { + ls.mutex.Lock() + ls.output += msg + ls.mutex.Unlock() +} + +func (ls *TestLogSystem) SetLogLevel(i LogLevel) { + ls.mutex.Lock() + ls.level = i + ls.mutex.Unlock() +} + +func (ls *TestLogSystem) GetLogLevel() LogLevel { + ls.mutex.Lock() + defer ls.mutex.Unlock() + return ls.level +} + +func (ls *TestLogSystem) CheckOutput(t *testing.T, expected string) { + ls.mutex.Lock() + output := ls.output + ls.mutex.Unlock() + if output != expected { + t.Errorf("log output mismatch:\n got: %q\n want: %q\n", output, expected) + } +} + +type blockedLogSystem struct { + LogSystem + unblock chan struct{} +} + +func (ls blockedLogSystem) LogPrint(level LogLevel, msg string) { + <-ls.unblock + ls.LogSystem.LogPrint(level, msg) +} + +func TestLoggerFlush(t *testing.T) { + Reset() + + logger := NewLogger("TEST") + ls := blockedLogSystem{&TestLogSystem{level: WarnLevel}, make(chan struct{})} + AddLogSystem(ls) + for i := 0; i < 5; i++ { + // these writes shouldn't hang even though ls is blocked + logger.Errorf(".") + } + + beforeFlush := time.Now() + time.AfterFunc(80*time.Millisecond, func() { close(ls.unblock) }) + Flush() // this should hang for approx. 80ms + if blockd := time.Now().Sub(beforeFlush); blockd < 80*time.Millisecond { + t.Errorf("Flush didn't block long enough, blocked for %v, should've been >= 80ms", blockd) + } + + ls.LogSystem.(*TestLogSystem).CheckOutput(t, "[TEST] .[TEST] .[TEST] .[TEST] .[TEST] .") +} + +func TestLoggerPrintln(t *testing.T) { + Reset() + + logger := NewLogger("TEST") + testLogSystem := &TestLogSystem{level: WarnLevel} + AddLogSystem(testLogSystem) + logger.Errorln("error") + logger.Warnln("warn") + logger.Infoln("info") + logger.Debugln("debug") + Flush() + + testLogSystem.CheckOutput(t, "[TEST] error\n[TEST] warn\n") +} + +func TestLoggerPrintf(t *testing.T) { + Reset() + + logger := NewLogger("TEST") + testLogSystem := &TestLogSystem{level: WarnLevel} + AddLogSystem(testLogSystem) + logger.Errorf("error to %v\n", []int{1, 2, 3}) + logger.Warnf("warn %%d %d", 5) + logger.Infof("info") + logger.Debugf("debug") + Flush() + testLogSystem.CheckOutput(t, "[TEST] error to [1 2 3]\n[TEST] warn %d 5") +} + +func TestMultipleLogSystems(t *testing.T) { + Reset() + + logger := NewLogger("TEST") + testLogSystem0 := &TestLogSystem{level: ErrorLevel} + testLogSystem1 := &TestLogSystem{level: WarnLevel} + AddLogSystem(testLogSystem0) + AddLogSystem(testLogSystem1) + logger.Errorln("error") + logger.Warnln("warn") + Flush() + + testLogSystem0.CheckOutput(t, "[TEST] error\n") + testLogSystem1.CheckOutput(t, "[TEST] error\n[TEST] warn\n") +} + +func TestFileLogSystem(t *testing.T) { + Reset() + + logger := NewLogger("TEST") + filename := "test.log" + file, _ := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, os.ModePerm) + testLogSystem := NewStdLogSystem(file, 0, WarnLevel) + AddLogSystem(testLogSystem) + logger.Errorf("error to %s\n", filename) + logger.Warnln("warn") + Flush() + contents, _ := ioutil.ReadFile(filename) + output := string(contents) + if output != "[TEST] error to test.log\n[TEST] warn\n" { + t.Error("Expected contents of file 'test.log': '[TEST] error to test.log\\n[TEST] warn\\n', got ", output) + } else { + os.Remove(filename) + } +} + +func TestNoLogSystem(t *testing.T) { + Reset() + + logger := NewLogger("TEST") + logger.Warnln("warn") + Flush() +} + +func TestConcurrentAddSystem(t *testing.T) { + rand.Seed(time.Now().Unix()) + Reset() + + logger := NewLogger("TEST") + stop := make(chan struct{}) + writer := func() { + select { + case <-stop: + return + default: + logger.Infoln("foo") + Flush() + } + } + + go writer() + go writer() + + stopTime := time.Now().Add(100 * time.Millisecond) + for time.Now().Before(stopTime) { + time.Sleep(time.Duration(rand.Intn(20)) * time.Millisecond) + AddLogSystem(NewStdLogSystem(ioutil.Discard, 0, InfoLevel)) + } + close(stop) +} diff --git a/logger/logsystem.go b/logger/logsystem.go new file mode 100644 index 000000000..8458b938f --- /dev/null +++ b/logger/logsystem.go @@ -0,0 +1,63 @@ +package logger + +import ( + "io" + "log" + "sync/atomic" +) + +// LogSystem is implemented by log output devices. +// All methods can be called concurrently from multiple goroutines. +type LogSystem interface { + GetLogLevel() LogLevel + SetLogLevel(i LogLevel) + LogPrint(LogLevel, string) +} + +// NewStdLogSystem creates a LogSystem that prints to the given writer. +// The flag values are defined package log. +func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem { + logger := log.New(writer, "", flags) + return &stdLogSystem{logger, uint32(level)} +} + +type stdLogSystem struct { + logger *log.Logger + level uint32 +} + +func (t *stdLogSystem) LogPrint(level LogLevel, msg string) { + t.logger.Print(msg) +} + +func (t *stdLogSystem) SetLogLevel(i LogLevel) { + atomic.StoreUint32(&t.level, uint32(i)) +} + +func (t *stdLogSystem) GetLogLevel() LogLevel { + return LogLevel(atomic.LoadUint32(&t.level)) +} + +// NewRawLogSystem creates a LogSystem that prints to the given writer without +// adding extra information. Suitable for preformatted output +func NewRawLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem { + logger := log.New(writer, "", 0) + return &rawLogSystem{logger, uint32(level)} +} + +type rawLogSystem struct { + logger *log.Logger + level uint32 +} + +func (t *rawLogSystem) LogPrint(level LogLevel, msg string) { + t.logger.Print(msg) +} + +func (t *rawLogSystem) SetLogLevel(i LogLevel) { + atomic.StoreUint32(&t.level, uint32(i)) +} + +func (t *rawLogSystem) GetLogLevel() LogLevel { + return LogLevel(atomic.LoadUint32(&t.level)) +} diff --git a/logger/sys.go b/logger/sys.go new file mode 100644 index 000000000..bd826b587 --- /dev/null +++ b/logger/sys.go @@ -0,0 +1,112 @@ +package logger + +import ( + "sync" +) + +type message struct { + level LogLevel + msg string +} + +var ( + logMessageC = make(chan message) + addSystemC = make(chan LogSystem) + flushC = make(chan chan struct{}) + resetC = make(chan chan struct{}) +) + +func init() { + go dispatchLoop() +} + +// each system can buffer this many messages before +// blocking incoming log messages. +const sysBufferSize = 500 + +func dispatchLoop() { + var ( + systems []LogSystem + systemIn []chan message + systemWG sync.WaitGroup + ) + bootSystem := func(sys LogSystem) { + in := make(chan message, sysBufferSize) + systemIn = append(systemIn, in) + systemWG.Add(1) + go sysLoop(sys, in, &systemWG) + } + + for { + select { + case msg := <-logMessageC: + for _, c := range systemIn { + c <- msg + } + + case sys := <-addSystemC: + systems = append(systems, sys) + bootSystem(sys) + + case waiter := <-resetC: + // reset means terminate all systems + for _, c := range systemIn { + close(c) + } + systems = nil + systemIn = nil + systemWG.Wait() + close(waiter) + + case waiter := <-flushC: + // flush means reboot all systems + for _, c := range systemIn { + close(c) + } + systemIn = nil + systemWG.Wait() + for _, sys := range systems { + bootSystem(sys) + } + close(waiter) + } + } +} + +func sysLoop(sys LogSystem, in <-chan message, wg *sync.WaitGroup) { + for msg := range in { + switch sys.(type) { + case *rawLogSystem: + // This is a semantic hack since rawLogSystem has little to do with JsonLevel + if msg.level == JsonLevel { + sys.LogPrint(msg.level, msg.msg) + } + default: + if sys.GetLogLevel() >= msg.level { + sys.LogPrint(msg.level, msg.msg) + } + } + } + wg.Done() +} + +// Reset removes all active log systems. +// It blocks until all current messages have been delivered. +func Reset() { + waiter := make(chan struct{}) + resetC <- waiter + <-waiter +} + +// Flush waits until all current log messages have been dispatched to +// the active log systems. +func Flush() { + waiter := make(chan struct{}) + flushC <- waiter + <-waiter +} + +// AddLogSystem starts printing messages to the given LogSystem. +func AddLogSystem(sys LogSystem) { + addSystemC <- sys +} diff --git a/logger/types.go b/logger/types.go new file mode 100644 index 000000000..7ab4a2b8c --- /dev/null +++ b/logger/types.go @@ -0,0 +1,359 @@ +package logger + +import ( + "time" +) + +type utctime8601 struct{} + +func (utctime8601) MarshalJSON() ([]byte, error) { + return []byte(`"` + time.Now().UTC().Format(time.RFC3339Nano)[:26] + `Z"`), nil +} + +type JsonLog interface { + EventName() string +} + +type LogEvent struct { + // Guid string `json:"guid"` + Ts utctime8601 `json:"ts"` + // Level string `json:"level"` +} + +type LogStarting struct { + ClientString string `json:"client_impl"` + ProtocolVersion int `json:"eth_version"` + LogEvent +} + +func (l *LogStarting) EventName() string { + return "starting" +} + +type P2PConnected struct { + RemoteId string `json:"remote_id"` + RemoteAddress string `json:"remote_addr"` + RemoteVersionString string `json:"remote_version_string"` + NumConnections int `json:"num_connections"` + LogEvent +} + +func (l *P2PConnected) EventName() string { + return "p2p.connected" +} + +type P2PDisconnected struct { + NumConnections int `json:"num_connections"` + RemoteId string `json:"remote_id"` + LogEvent +} + +func (l *P2PDisconnected) EventName() string { + return "p2p.disconnected" +} + +type EthMinerNewBlock struct { + BlockHash string `json:"block_hash"` + BlockNumber int `json:"block_number"` + ChainHeadHash string `json:"chain_head_hash"` + BlockPrevHash string `json:"block_prev_hash"` + LogEvent +} + +func (l *EthMinerNewBlock) EventName() string { + return "eth.miner.new_block" +} + +type EthChainReceivedNewBlock struct { + BlockHash string `json:"block_hash"` + BlockNumber int `json:"block_number"` + ChainHeadHash string `json:"chain_head_hash"` + BlockPrevHash string `json:"block_prev_hash"` + RemoteId int `json:"remote_id"` + LogEvent +} + +func (l *EthChainReceivedNewBlock) EventName() string { + return "eth.chain.received.new_block" +} + +type EthChainNewHead struct { + BlockHash string `json:"block_hash"` + BlockNumber int `json:"block_number"` + ChainHeadHash string `json:"chain_head_hash"` + BlockPrevHash string `json:"block_prev_hash"` + LogEvent +} + +func (l *EthChainNewHead) EventName() string { + return "eth.chain.new_head" +} + +type EthTxReceived struct { + TxHash string `json:"tx_hash"` + RemoteId string `json:"remote_id"` + LogEvent +} + +func (l *EthTxReceived) EventName() string { + return "eth.tx.received" +} + +// +// +// The types below are legacy and need to be converted to new format or deleted +// +// + +// type P2PConnecting struct { +// RemoteId string `json:"remote_id"` +// RemoteEndpoint string `json:"remote_endpoint"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PConnecting) EventName() string { +// return "p2p.connecting" +// } + +// type P2PHandshaked struct { +// RemoteCapabilities []string `json:"remote_capabilities"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PHandshaked) EventName() string { +// return "p2p.handshaked" +// } + +// type P2PDisconnecting struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PDisconnecting) EventName() string { +// return "p2p.disconnecting" +// } + +// type P2PDisconnectingBadHandshake struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PDisconnectingBadHandshake) EventName() string { +// return "p2p.disconnecting.bad_handshake" +// } + +// type P2PDisconnectingBadProtocol struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PDisconnectingBadProtocol) EventName() string { +// return "p2p.disconnecting.bad_protocol" +// } + +// type P2PDisconnectingReputation struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PDisconnectingReputation) EventName() string { +// return "p2p.disconnecting.reputation" +// } + +// type P2PDisconnectingDHT struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PDisconnectingDHT) EventName() string { +// return "p2p.disconnecting.dht" +// } + +// type P2PEthDisconnectingBadBlock struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PEthDisconnectingBadBlock) EventName() string { +// return "p2p.eth.disconnecting.bad_block" +// } + +// type P2PEthDisconnectingBadTx struct { +// Reason string `json:"reason"` +// RemoteId string `json:"remote_id"` +// NumConnections int `json:"num_connections"` +// LogEvent +// } + +// func (l *P2PEthDisconnectingBadTx) EventName() string { +// return "p2p.eth.disconnecting.bad_tx" +// } + +// type EthNewBlockBroadcasted struct { +// 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 +// } + +// func (l *EthNewBlockBroadcasted) EventName() string { +// return "eth.newblock.broadcasted" +// } + +// type EthNewBlockIsKnown struct { +// 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 +// } + +// func (l *EthNewBlockIsKnown) EventName() string { +// return "eth.newblock.is_known" +// } + +// type EthNewBlockIsNew struct { +// 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 +// } + +// func (l *EthNewBlockIsNew) EventName() string { +// return "eth.newblock.is_new" +// } + +// type EthNewBlockMissingParent struct { +// 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 +// } + +// func (l *EthNewBlockMissingParent) EventName() string { +// return "eth.newblock.missing_parent" +// } + +// type EthNewBlockIsInvalid struct { +// 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 +// } + +// func (l *EthNewBlockIsInvalid) EventName() string { +// return "eth.newblock.is_invalid" +// } + +// type EthNewBlockChainIsOlder struct { +// 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 +// } + +// func (l *EthNewBlockChainIsOlder) EventName() string { +// return "eth.newblock.chain.is_older" +// } + +// type EthNewBlockChainIsCanonical struct { +// 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 +// } + +// func (l *EthNewBlockChainIsCanonical) EventName() string { +// return "eth.newblock.chain.is_cannonical" +// } + +// type EthNewBlockChainNotCanonical struct { +// 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 +// } + +// func (l *EthNewBlockChainNotCanonical) EventName() string { +// return "eth.newblock.chain.not_cannonical" +// } + +// type EthTxCreated struct { +// 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 +// } + +// func (l *EthTxCreated) EventName() string { +// return "eth.tx.created" +// } + +// type EthTxBroadcasted struct { +// TxHash string `json:"tx_hash"` +// TxSender string `json:"tx_sender"` +// TxAddress string `json:"tx_address"` +// TxNonce int `json:"tx_nonce"` +// LogEvent +// } + +// func (l *EthTxBroadcasted) EventName() string { +// return "eth.tx.broadcasted" +// } + +// type EthTxValidated struct { +// TxHash string `json:"tx_hash"` +// TxSender string `json:"tx_sender"` +// TxAddress string `json:"tx_address"` +// TxNonce int `json:"tx_nonce"` +// LogEvent +// } + +// func (l *EthTxValidated) EventName() string { +// return "eth.tx.validated" +// } + +// type EthTxIsInvalid struct { +// 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 +// } + +// func (l *EthTxIsInvalid) EventName() string { +// return "eth.tx.is_invalid" +// } |