diff options
-rw-r--r-- | javascript/types.go | 44 | ||||
-rw-r--r-- | websocket/util.go | 6 |
2 files changed, 19 insertions, 31 deletions
diff --git a/javascript/types.go b/javascript/types.go index 61a57033b..d85e24c88 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -38,31 +38,19 @@ func (self *JSBlock) GetTransaction(hash string) otto.Value { return self.eth.toVal(self.JSBlock.GetTransaction(hash)) } -type JSMessage struct { - To string `json:"to"` - From string `json:"from"` - Input string `json:"input"` - Output string `json:"output"` - Path int `json:"path"` - Origin string `json:"origin"` - Timestamp int32 `json:"timestamp"` - Coinbase string `json:"coinbase"` - Block string `json:"block"` - Number int32 `json:"number"` +type JSLog struct { + Address string `json:address` + Topics []string `json:topics` + Number int32 `json:number` + Data string `json:data` } -func NewJSMessage(message *state.Message) JSMessage { - return JSMessage{ - To: ethutil.Bytes2Hex(message.To), - From: ethutil.Bytes2Hex(message.From), - Input: ethutil.Bytes2Hex(message.Input), - Output: ethutil.Bytes2Hex(message.Output), - Path: message.Path, - Origin: ethutil.Bytes2Hex(message.Origin), - Timestamp: int32(message.Timestamp), - Coinbase: ethutil.Bytes2Hex(message.Origin), - Block: ethutil.Bytes2Hex(message.Block), - Number: int32(message.Number.Int64()), +func NewJSLog(log state.Log) JSLog { + return JSLog{ + Address: ethutil.Bytes2Hex(log.Address()), + Topics: nil, //ethutil.Bytes2Hex(log.Address()), + Number: 0, + Data: ethutil.Bytes2Hex(log.Data()), } } @@ -120,13 +108,13 @@ func (self *JSEthereum) toVal(v interface{}) otto.Value { func (self *JSEthereum) Messages(object map[string]interface{}) otto.Value { filter := ui.NewFilterFromMap(object, self.ethereum) - messages := filter.Find() - var msgs []JSMessage - for _, m := range messages { - msgs = append(msgs, NewJSMessage(m)) + logs := filter.Find() + var jslogs []JSLog + for _, m := range logs { + jslogs = append(jslogs, NewJSLog(m)) } - v, _ := self.vm.ToValue(msgs) + v, _ := self.vm.ToValue(jslogs) return v } diff --git a/websocket/util.go b/websocket/util.go index 943032b06..3c1388de0 100644 --- a/websocket/util.go +++ b/websocket/util.go @@ -119,8 +119,8 @@ func (self *WebSocketServer) Serv() { if mp, ok := msg.Args[0].(map[string]interface{}); ok { var id int filter := ui.NewFilterFromMap(mp, self.eth) - filter.MessageCallback = func(messages state.Messages) { - c.Event(toMessages(messages), "eth_changed", id) + filter.LogsCallback = func(logs state.Logs) { + //c.Event(toMessages(messages), "eth_changed", id) } id = self.filterManager.InstallFilter(filter) c.Write(id, msg.Id) @@ -136,7 +136,7 @@ func (self *WebSocketServer) Serv() { case "eth_filterLogs": filter := self.filterManager.GetFilter(int(msg.Arguments().Get(0).Uint())) if filter != nil { - c.Write(toMessages(filter.Find()), msg.Id) + //c.Write(toMessages(filter.Find()), msg.Id) } } |