diff --git a/cmd/ethereum/repl/repl.go b/cmd/ethereum/repl/repl.go index 822aaa19d..78bb19cec 100644 --- a/cmd/ethereum/repl/repl.go +++ b/cmd/ethereum/repl/repl.go @@ -86,6 +86,7 @@ func (self *JSRepl) Stop() { } func (self *JSRepl) parseInput(code string) { + value, err := self.re.Run(code) if err != nil { fmt.Println(err) diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 3349c9441..fa284e52d 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "gopkg.in/fatih/set.v0" @@ -107,7 +108,14 @@ func (self *TxPool) Add(tx *types.Transaction) error { self.addTransaction(tx) - txplogger.Debugf("(t) %x => %x (%v) %x\n", tx.From()[:4], tx.To()[:4], tx.Value, tx.Hash()) + var to string + if len(tx.To()) > 0 { + to = ethutil.Bytes2Hex(tx.To()[:4]) + } else { + to = "[NEW_CONTRACT]" + } + + txplogger.Debugf("(t) %x => %s (%v) %x\n", tx.From()[:4], to, tx.Value, tx.Hash()) // Notify the subscribers go self.eventMux.Post(TxPreEvent{tx}) diff --git a/eth/backend.go b/eth/backend.go index 78c2159c0..36c1ac30f 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -234,8 +234,10 @@ func (self *Ethereum) txBroadcastLoop() { func (self *Ethereum) blockBroadcastLoop() { // automatically stops if unsubscribe for obj := range self.txSub.Chan() { - event := obj.(core.NewMinedBlockEvent) - self.server.Broadcast("eth", NewBlockMsg, event.Block.RlpData()) + switch ev := obj.(type) { + case core.NewMinedBlockEvent: + self.server.Broadcast("eth", NewBlockMsg, ev.Block.RlpData()) + } } } diff --git a/javascript/types.go b/javascript/types.go index ce1d9995a..61a57033b 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -72,15 +72,21 @@ type JSEthereum struct { ethereum *eth.Ethereum } -func (self *JSEthereum) GetBlock(hash string) otto.Value { - return self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self}) +func (self *JSEthereum) Block(v interface{}) otto.Value { + if number, ok := v.(int64); ok { + return self.toVal(&JSBlock{self.JSXEth.BlockByNumber(int32(number)), self}) + } else if hash, ok := v.(string); ok { + return self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self}) + } + + return otto.UndefinedValue() } -func (self *JSEthereum) GetPeers() otto.Value { +func (self *JSEthereum) Peers() otto.Value { return self.toVal(self.JSXEth.Peers()) } -func (self *JSEthereum) GetKey() otto.Value { +func (self *JSEthereum) Key() otto.Value { return self.toVal(self.JSXEth.Key()) } @@ -88,10 +94,6 @@ func (self *JSEthereum) GetStateObject(addr string) otto.Value { return self.toVal(&JSStateObject{xeth.NewJSObject(self.JSXEth.World().SafeGet(ethutil.Hex2Bytes(addr))), self}) } -func (self *JSEthereum) Peers() otto.Value { - return self.toVal(self.JSXEth.Peers()) -} - func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { r, err := self.JSXEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) if err != nil { @@ -103,18 +105,6 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, return self.toVal(r) } -func (self *JSEthereum) Create(key, valueStr, gasStr, gasPriceStr, scriptStr string) otto.Value { - r, err := self.JSXEth.Transact(key, "", valueStr, gasStr, gasPriceStr, scriptStr) - - if err != nil { - fmt.Println(err) - - return otto.UndefinedValue() - } - - return self.toVal(r) -} - func (self *JSEthereum) toVal(v interface{}) otto.Value { result, err := self.vm.ToValue(v) diff --git a/vm/analysis.go b/vm/analysis.go index 501fbfc4a..411df5686 100644 --- a/vm/analysis.go +++ b/vm/analysis.go @@ -12,7 +12,6 @@ func analyseJumpDests(code []byte) (dests *set.Set) { a := uint64(op) - uint64(PUSH1) + 1 pc += a - //lp = true case JUMPDEST: dests.Add(pc) }