updated messages

pull/272/merge
obscuren 10 years ago
parent 4c5968097d
commit f15d23b496
  1. 48
      javascript/types.go
  2. 6
      websocket/util.go

@ -38,31 +38,19 @@ func (self *JSBlock) GetTransaction(hash string) otto.Value {
return self.eth.toVal(self.JSBlock.GetTransaction(hash)) return self.eth.toVal(self.JSBlock.GetTransaction(hash))
} }
type JSMessage struct { type JSLog struct {
To string `json:"to"` Address string `json:address`
From string `json:"from"` Topics []string `json:topics`
Input string `json:"input"` Number int32 `json:number`
Output string `json:"output"` Data string `json:data`
Path int `json:"path"` }
Origin string `json:"origin"`
Timestamp int32 `json:"timestamp"` func NewJSLog(log state.Log) JSLog {
Coinbase string `json:"coinbase"` return JSLog{
Block string `json:"block"` Address: ethutil.Bytes2Hex(log.Address()),
Number int32 `json:"number"` Topics: nil, //ethutil.Bytes2Hex(log.Address()),
} Number: 0,
Data: ethutil.Bytes2Hex(log.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()),
} }
} }
@ -120,13 +108,13 @@ func (self *JSEthereum) toVal(v interface{}) otto.Value {
func (self *JSEthereum) Messages(object map[string]interface{}) otto.Value { func (self *JSEthereum) Messages(object map[string]interface{}) otto.Value {
filter := ui.NewFilterFromMap(object, self.ethereum) filter := ui.NewFilterFromMap(object, self.ethereum)
messages := filter.Find() logs := filter.Find()
var msgs []JSMessage var jslogs []JSLog
for _, m := range messages { for _, m := range logs {
msgs = append(msgs, NewJSMessage(m)) jslogs = append(jslogs, NewJSLog(m))
} }
v, _ := self.vm.ToValue(msgs) v, _ := self.vm.ToValue(jslogs)
return v return v
} }

@ -119,8 +119,8 @@ func (self *WebSocketServer) Serv() {
if mp, ok := msg.Args[0].(map[string]interface{}); ok { if mp, ok := msg.Args[0].(map[string]interface{}); ok {
var id int var id int
filter := ui.NewFilterFromMap(mp, self.eth) filter := ui.NewFilterFromMap(mp, self.eth)
filter.MessageCallback = func(messages state.Messages) { filter.LogsCallback = func(logs state.Logs) {
c.Event(toMessages(messages), "eth_changed", id) //c.Event(toMessages(messages), "eth_changed", id)
} }
id = self.filterManager.InstallFilter(filter) id = self.filterManager.InstallFilter(filter)
c.Write(id, msg.Id) c.Write(id, msg.Id)
@ -136,7 +136,7 @@ func (self *WebSocketServer) Serv() {
case "eth_filterLogs": case "eth_filterLogs":
filter := self.filterManager.GetFilter(int(msg.Arguments().Get(0).Uint())) filter := self.filterManager.GetFilter(int(msg.Arguments().Get(0).Uint()))
if filter != nil { if filter != nil {
c.Write(toMessages(filter.Find()), msg.Id) //c.Write(toMessages(filter.Find()), msg.Id)
} }
} }

Loading…
Cancel
Save