diff options
author | Alexandre Van de Sande <alex.vandesande@ethdev.com> | 2015-02-23 20:05:15 +0800 |
---|---|---|
committer | Alexandre Van de Sande <alex.vandesande@ethdev.com> | 2015-02-23 20:05:15 +0800 |
commit | dea65840186fe861017524c9cb59ae07ac97ed06 (patch) | |
tree | 5cb5e339b9ce77a2a3c92cf8a10c4294fcf7965c /rpc/util.go | |
parent | bb3338df6363d8267a24190584f0908463241a6c (diff) | |
parent | dd086791acf477da7641c168f82de70ed0b2dca6 (diff) | |
download | go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.tar go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.tar.gz go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.tar.bz2 go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.tar.lz go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.tar.xz go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.tar.zst go-tangerine-dea65840186fe861017524c9cb59ae07ac97ed06.zip |
Merge branch 'develop' into ui
Diffstat (limited to 'rpc/util.go')
-rw-r--r-- | rpc/util.go | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/rpc/util.go b/rpc/util.go index 679d83754..1939b3474 100644 --- a/rpc/util.go +++ b/rpc/util.go @@ -20,10 +20,12 @@ import ( "encoding/json" "io" "net/http" + "time" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/state" + "github.com/ethereum/go-ethereum/xeth" ) var rpclogger = logger.NewLogger("RPC") @@ -80,8 +82,9 @@ type RpcServer interface { type Log struct { Address string `json:"address"` - Topics []string `json:"topics"` + Topic []string `json:"topics"` Data string `json:"data"` + Number uint64 `json:"number"` } func toLogs(logs state.Logs) (ls []Log) { @@ -89,14 +92,46 @@ func toLogs(logs state.Logs) (ls []Log) { for i, log := range logs { var l Log - l.Topics = make([]string, len(log.Topics())) + l.Topic = make([]string, len(log.Topics())) l.Address = toHex(log.Address()) l.Data = toHex(log.Data()) + l.Number = log.Number() for j, topic := range log.Topics() { - l.Topics[j] = toHex(topic) + l.Topic[j] = toHex(topic) } ls[i] = l } return } + +type whisperFilter struct { + messages []xeth.WhisperMessage + timeout time.Time +} + +func (w *whisperFilter) add(msgs ...xeth.WhisperMessage) { + w.messages = append(w.messages, msgs...) +} +func (w *whisperFilter) get() []xeth.WhisperMessage { + w.timeout = time.Now() + tmp := w.messages + w.messages = nil + return tmp +} + +type logFilter struct { + logs state.Logs + timeout time.Time +} + +func (l *logFilter) add(logs ...state.Log) { + l.logs = append(l.logs, logs...) +} + +func (l *logFilter) get() state.Logs { + l.timeout = time.Now() + tmp := l.logs + l.logs = nil + return tmp +} |