Changed to ChainEvent and fixed a nil pointer in transact

pull/339/head
obscuren 10 years ago
parent 11e12680eb
commit 7fc9b5b3f9
  1. 4
      cmd/mist/assets/examples/info.html
  2. 6
      cmd/mist/gui.go
  3. 2
      core/chain_manager.go
  4. 4
      eth/backend.go
  5. 7
      event/filter/eth_filter.go
  6. 29
      rpc/args.go
  7. 6
      rpc/packages.go
  8. 3
      xeth/xeth.go

@ -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;
});
</script>
</html>

@ -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

@ -393,8 +393,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
}
self.mu.Unlock()
self.eventMux.Post(NewBlockEvent{block})
}
return nil

@ -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"),
}
)

@ -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 {

@ -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"`
}

@ -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())

@ -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)

Loading…
Cancel
Save