Fixed bug where logging could crash client during tx adding
This commit is contained in:
parent
5c82fdc243
commit
16f417f5af
@ -86,6 +86,7 @@ func (self *JSRepl) Stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSRepl) parseInput(code string) {
|
func (self *JSRepl) parseInput(code string) {
|
||||||
|
|
||||||
value, err := self.re.Run(code)
|
value, err := self.re.Run(code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
"github.com/ethereum/go-ethereum/logger"
|
"github.com/ethereum/go-ethereum/logger"
|
||||||
"gopkg.in/fatih/set.v0"
|
"gopkg.in/fatih/set.v0"
|
||||||
@ -107,7 +108,14 @@ func (self *TxPool) Add(tx *types.Transaction) error {
|
|||||||
|
|
||||||
self.addTransaction(tx)
|
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
|
// Notify the subscribers
|
||||||
go self.eventMux.Post(TxPreEvent{tx})
|
go self.eventMux.Post(TxPreEvent{tx})
|
||||||
|
@ -234,8 +234,10 @@ func (self *Ethereum) txBroadcastLoop() {
|
|||||||
func (self *Ethereum) blockBroadcastLoop() {
|
func (self *Ethereum) blockBroadcastLoop() {
|
||||||
// automatically stops if unsubscribe
|
// automatically stops if unsubscribe
|
||||||
for obj := range self.txSub.Chan() {
|
for obj := range self.txSub.Chan() {
|
||||||
event := obj.(core.NewMinedBlockEvent)
|
switch ev := obj.(type) {
|
||||||
self.server.Broadcast("eth", NewBlockMsg, event.Block.RlpData())
|
case core.NewMinedBlockEvent:
|
||||||
|
self.server.Broadcast("eth", NewBlockMsg, ev.Block.RlpData())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,15 +72,21 @@ type JSEthereum struct {
|
|||||||
ethereum *eth.Ethereum
|
ethereum *eth.Ethereum
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetBlock(hash string) otto.Value {
|
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 self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetPeers() otto.Value {
|
return otto.UndefinedValue()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *JSEthereum) Peers() otto.Value {
|
||||||
return self.toVal(self.JSXEth.Peers())
|
return self.toVal(self.JSXEth.Peers())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetKey() otto.Value {
|
func (self *JSEthereum) Key() otto.Value {
|
||||||
return self.toVal(self.JSXEth.Key())
|
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})
|
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 {
|
func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value {
|
||||||
r, err := self.JSXEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
|
r, err := self.JSXEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -103,18 +105,6 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr,
|
|||||||
return self.toVal(r)
|
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 {
|
func (self *JSEthereum) toVal(v interface{}) otto.Value {
|
||||||
result, err := self.vm.ToValue(v)
|
result, err := self.vm.ToValue(v)
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ func analyseJumpDests(code []byte) (dests *set.Set) {
|
|||||||
a := uint64(op) - uint64(PUSH1) + 1
|
a := uint64(op) - uint64(PUSH1) + 1
|
||||||
|
|
||||||
pc += a
|
pc += a
|
||||||
//lp = true
|
|
||||||
case JUMPDEST:
|
case JUMPDEST:
|
||||||
dests.Add(pc)
|
dests.Add(pc)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user