aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 02:19:52 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-20 02:19:52 +0800
commitd670c861d7b7acb9983fdad065b2b67b0d598c45 (patch)
tree9c835f728fda1cfe00f79534c77913ec9cf5f925
parent0685810ec604134bdf5b4ea555722909f72a7f57 (diff)
downloaddexon-d670c861d7b7acb9983fdad065b2b67b0d598c45.tar.gz
dexon-d670c861d7b7acb9983fdad065b2b67b0d598c45.tar.zst
dexon-d670c861d7b7acb9983fdad065b2b67b0d598c45.zip
Move Log to LogRes
-rw-r--r--rpc/api.go6
-rw-r--r--rpc/responses.go26
-rw-r--r--rpc/util.go26
3 files changed, 29 insertions, 29 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 6154a0b28..792498547 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -208,7 +208,7 @@ func (self *EthereumApi) FilterChanged(id int, reply *interface{}) error {
defer self.logMut.Unlock()
if self.logs[id] != nil {
- *reply = toLogs(self.logs[id].get())
+ *reply = NewLogsRes(self.logs[id].get())
}
return nil
@@ -220,7 +220,7 @@ func (self *EthereumApi) Logs(id int, reply *interface{}) error {
filter := self.filterManager.GetFilter(id)
if filter != nil {
- *reply = toLogs(filter.Find())
+ *reply = NewLogsRes(filter.Find())
}
return nil
@@ -230,7 +230,7 @@ func (self *EthereumApi) AllLogs(args *FilterOptions, reply *interface{}) error
filter := core.NewFilter(self.xeth().Backend())
filter.SetOptions(toFilterOptions(args))
- *reply = toLogs(filter.Find())
+ *reply = NewLogsRes(filter.Find())
return nil
}
diff --git a/rpc/responses.go b/rpc/responses.go
index eec483fb7..a3613f380 100644
--- a/rpc/responses.go
+++ b/rpc/responses.go
@@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/state"
)
type BlockRes struct {
@@ -211,3 +212,28 @@ type FilterWhisperRes struct {
Payload string `json:"payload"`
WorkProved string `json:"workProved"`
}
+
+type LogRes struct {
+ Address string `json:"address"`
+ Topic []string `json:"topic"`
+ Data string `json:"data"`
+ Number uint64 `json:"number"`
+}
+
+func NewLogsRes(logs state.Logs) (ls []LogRes) {
+ ls = make([]LogRes, len(logs))
+
+ for i, log := range logs {
+ var l LogRes
+ l.Topic = make([]string, len(log.Topics()))
+ l.Address = common.ToHex(log.Address())
+ l.Data = common.ToHex(log.Data())
+ l.Number = log.Number()
+ for j, topic := range log.Topics() {
+ l.Topic[j] = common.ToHex(topic)
+ }
+ ls[i] = l
+ }
+
+ return
+}
diff --git a/rpc/util.go b/rpc/util.go
index 0798ae1d2..9a1d11bf1 100644
--- a/rpc/util.go
+++ b/rpc/util.go
@@ -19,7 +19,6 @@ package rpc
import (
"time"
- "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/xeth"
@@ -27,31 +26,6 @@ import (
var rpclogger = logger.NewLogger("RPC")
-type Log struct {
- Address string `json:"address"`
- Topic []string `json:"topic"`
- Data string `json:"data"`
- Number uint64 `json:"number"`
-}
-
-func toLogs(logs state.Logs) (ls []Log) {
- ls = make([]Log, len(logs))
-
- for i, log := range logs {
- var l Log
- l.Topic = make([]string, len(log.Topics()))
- l.Address = common.ToHex(log.Address())
- l.Data = common.ToHex(log.Data())
- l.Number = log.Number()
- for j, topic := range log.Topics() {
- l.Topic[j] = common.ToHex(topic)
- }
- ls[i] = l
- }
-
- return
-}
-
type whisperFilter struct {
messages []xeth.WhisperMessage
timeout time.Time