aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/util.go
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2015-02-24 01:39:05 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2015-02-24 01:39:05 +0800
commit114c3b4efe7f30ab7be0bec013210e7b4c3d08d7 (patch)
tree5230f6fee87dcbac36e1d71d6ab731b55eab8268 /rpc/util.go
parentb9894c1d0979b9f3e8428b1dc230f1ece106f676 (diff)
parentdd086791acf477da7641c168f82de70ed0b2dca6 (diff)
downloaddexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.tar
dexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.tar.gz
dexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.tar.bz2
dexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.tar.lz
dexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.tar.xz
dexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.tar.zst
dexon-114c3b4efe7f30ab7be0bec013210e7b4c3d08d7.zip
Merge remote-tracking branch 'upstream/develop' into evmjit
Diffstat (limited to 'rpc/util.go')
-rw-r--r--rpc/util.go43
1 files changed, 39 insertions, 4 deletions
diff --git a/rpc/util.go b/rpc/util.go
index 509d9a17d..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")
@@ -47,7 +49,6 @@ func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error)
// Convert JSON to native types
d := json.NewDecoder(req.Body)
- // d.UseNumber()
defer req.Body.Close()
err := d.Decode(&reqParsed)
@@ -55,6 +56,7 @@ func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error)
rpclogger.Errorln("Error decoding JSON: ", err)
return reqParsed, err
}
+
rpclogger.DebugDetailf("Parsed request: %s", reqParsed)
return reqParsed, nil
@@ -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
+}