diff --git a/cmd/mist/assets/examples/info.html b/cmd/mist/assets/examples/info.html index d8816b19fa..2a405c280a 100644 --- a/cmd/mist/assets/examples/info.html +++ b/cmd/mist/assets/examples/info.html @@ -71,6 +71,10 @@ document.querySelector("#gas_price").innerHTML = eth.gasPrice; document.querySelector("#mining").innerHTML = eth.mining; document.querySelector("#listening").innerHTML = eth.listening; + eth.watch('chain').changed(function() { + document.querySelector("#number").innerHTML = eth.number; + }); + diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 886a5811b2..c12538f4a1 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -394,7 +394,6 @@ func (gui *Gui) update() { miningLabel := gui.getObjectByName("miningLabel") events := gui.eth.EventMux().Subscribe( - core.NewBlockEvent{}, core.TxPreEvent{}, core.TxPostEvent{}, ) @@ -407,11 +406,6 @@ func (gui *Gui) update() { return } switch ev := ev.(type) { - case core.NewBlockEvent: - gui.processBlock(ev.Block, false) - balance := ethutil.CurrencyToString(gui.eth.ChainManager().State().GetBalance(gui.address())) - gui.getObjectByName("balanceLabel").Set("text", fmt.Sprintf("%v", balance)) - case core.TxPreEvent: tx := ev.Tx diff --git a/core/chain_manager.go b/core/chain_manager.go index 0256156765..22d54be03e 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -393,8 +393,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error { } } self.mu.Unlock() - - self.eventMux.Post(NewBlockEvent{block}) } return nil diff --git a/eth/backend.go b/eth/backend.go index 7685f3568e..9749cef9a9 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -25,8 +25,8 @@ var ( jsonlogger = ethlogger.NewJsonLogger() defaultBootNodes = []*discover.Node{ - discover.MustParseNode("enode://6cdd090303f394a1cac34ecc9f7cda18127eafa2a3a06de39f6d920b0e583e062a7362097c7c65ee490a758b442acd5c80c6fce4b148c6a391e946b45131365b@54.169.166.226:30303"), - discover.MustParseNode("enode://d1760a33c2f25c3b419ee4f6787fb0ea148828f5e678f0450d4be978fef908b42fc47a4c0fbf19832754f17881d381e50364fa93be42f31801d60ac64933f0a5@127.0.0.1:30303"), + //discover.MustParseNode("enode://6cdd090303f394a1cac34ecc9f7cda18127eafa2a3a06de39f6d920b0e583e062a7362097c7c65ee490a758b442acd5c80c6fce4b148c6a391e946b45131365b@54.169.166.226:30303"), + discover.MustParseNode("enode://364d179a050fb3192ea25ee2c4836cb808f13bb1a98a058e5bf215a597080edd742a00d6fd4b5f348a08024097f0b8f567610902dddf8db573362d8b22cabef5@127.0.0.1:30303"), } ) diff --git a/event/filter/eth_filter.go b/event/filter/eth_filter.go index 295fcfbbf9..d298d914d7 100644 --- a/event/filter/eth_filter.go +++ b/event/filter/eth_filter.go @@ -60,7 +60,10 @@ func (self *FilterManager) GetFilter(id int) *core.Filter { func (self *FilterManager) filterLoop() { // Subscribe to events - events := self.eventMux.Subscribe(core.PendingBlockEvent{}, core.NewBlockEvent{}, state.Logs(nil)) + events := self.eventMux.Subscribe( + core.PendingBlockEvent{}, + core.ChainEvent{}, + state.Logs(nil)) out: for { @@ -69,7 +72,7 @@ out: break out case event := <-events.Chan(): switch event := event.(type) { - case core.NewBlockEvent: + case core.ChainEvent: self.filterMu.RLock() for _, filter := range self.filters { if filter.BlockCallback != nil { diff --git a/rpc/args.go b/rpc/args.go index 9c2c7d7a6b..429b385d54 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -38,6 +38,35 @@ type NewTxArgs struct { Data string `json:"data"` } +func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) { + // Data can be either specified as "data" or "code" :-/ + var ext struct { + From string + To string + Value string + Gas string + GasPrice string + Data string + Code string + } + + if err = json.Unmarshal(b, &ext); err == nil { + if len(ext.Data) == 0 { + ext.Data = ext.Code + } + obj.From = ext.From + obj.To = ext.To + obj.Value = ext.Value + obj.Gas = ext.Gas + obj.GasPrice = ext.GasPrice + obj.Data = ext.Data + + return + } + + return NewErrorResponse(ErrorDecodeArgs) +} + type PushTxArgs struct { Tx string `json:"tx"` } diff --git a/rpc/packages.go b/rpc/packages.go index 0b73d48a77..4d21945711 100644 --- a/rpc/packages.go +++ b/rpc/packages.go @@ -127,6 +127,9 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error filter := core.NewFilter(self.xeth.Backend()) callback := func(block *types.Block) { + self.logMut.Lock() + defer self.logMut.Unlock() + self.logs[id] = append(self.logs[id], &state.StateLog{}) } if args == "pending" { @@ -153,6 +156,9 @@ func (self *EthereumApi) FilterChanged(id int, reply *interface{}) error { } func (self *EthereumApi) Logs(id int, reply *interface{}) error { + self.logMut.Lock() + defer self.logMut.Unlock() + filter := self.filterManager.GetFilter(id) *reply = toLogs(filter.Find()) diff --git a/xeth/xeth.go b/xeth/xeth.go index 27435b9565..f005105bb2 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -16,7 +16,6 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/p2p" - "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/whisper" ) @@ -220,7 +219,7 @@ func (self *XEth) Call(toStr, valueStr, gasStr, gasPriceStr, dataStr string) (st var ( statedb = self.chainManager.TransState() key = self.eth.KeyManager().KeyPair() - from = state.NewStateObject(key.Address(), self.eth.Db()) + from = statedb.GetOrNewStateObject(key.Address()) block = self.chainManager.CurrentBlock() to = statedb.GetOrNewStateObject(fromHex(toStr)) data = fromHex(dataStr)