aboutsummaryrefslogtreecommitdiffstats
path: root/javascript
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-03 05:19:58 +0800
committerobscuren <geffobscura@gmail.com>2015-01-03 05:19:58 +0800
commit16f417f5af16de8f1c2c140f8b249bd989200bd3 (patch)
treec0916e6cac3208a6a2ed889406a86ea3f71e433a /javascript
parent5c82fdc2434c302a2b65a4c7f25fe91b22cd43df (diff)
downloadgo-tangerine-16f417f5af16de8f1c2c140f8b249bd989200bd3.tar.gz
go-tangerine-16f417f5af16de8f1c2c140f8b249bd989200bd3.tar.zst
go-tangerine-16f417f5af16de8f1c2c140f8b249bd989200bd3.zip
Fixed bug where logging could crash client during tx adding
Diffstat (limited to 'javascript')
-rw-r--r--javascript/types.go30
1 files changed, 10 insertions, 20 deletions
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)