From b89ed8eb7bc9ced4a7daa33cc81e1579a6d2ddfc Mon Sep 17 00:00:00 2001 From: zelig Date: Sun, 14 Dec 2014 18:12:27 +0000 Subject: adapt javascript pkg to new backend, use SuggestPeer --- javascript/javascript_runtime.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'javascript/javascript_runtime.go') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 84d61d405..169ed509e 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -7,10 +7,10 @@ import ( "path" "path/filepath" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" @@ -202,7 +202,7 @@ func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value { if err != nil { return otto.FalseValue() } - self.ethereum.ConnectToPeer(host) + self.ethereum.SuggestPeer(host) return otto.TrueValue() } -- cgit v1.2.3 From fed3e6a808921fb8274b50043c5c39a24a1bbccf Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 7 Jan 2015 13:17:48 +0100 Subject: Refactored ethutil.Config.Db out --- javascript/javascript_runtime.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'javascript/javascript_runtime.go') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index af1405049..adc9022b7 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -129,10 +129,9 @@ func (self *JSRE) initStdFuncs() { */ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { - var state *state.StateDB + var block *types.Block if len(call.ArgumentList) > 0 { - var block *types.Block if call.Argument(0).IsNumber() { num, _ := call.Argument(0).ToInteger() block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num)) @@ -149,12 +148,12 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { return otto.UndefinedValue() } - state = block.State() } else { - state = self.ethereum.ChainManager().State() + block = self.ethereum.ChainManager().CurrentBlock() } - v, _ := self.Vm.ToValue(state.Dump()) + statedb := state.New(block.Root(), self.ethereum.Db()) + v, _ := self.Vm.ToValue(statedb.Dump()) return v } -- cgit v1.2.3 From 872b2497114209119becf2e8a4d4a5818e2084ee Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 28 Jan 2015 18:35:49 +0100 Subject: further cleaned up xeth interface --- javascript/javascript_runtime.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'javascript/javascript_runtime.go') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index adc9022b7..c780eb754 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -24,7 +24,7 @@ var jsrelogger = logger.NewLogger("JSRE") type JSRE struct { ethereum *eth.Ethereum Vm *otto.Otto - pipe *xeth.JSXEth + pipe *xeth.XEth events event.Subscription @@ -49,7 +49,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { re := &JSRE{ ethereum, otto.New(), - xeth.NewJSXEth(ethereum), + xeth.New(ethereum), nil, make(map[string][]otto.Value), } -- cgit v1.2.3 From 84adf77bf3492351de82f0ec820a1d280e85a5cd Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 29 Jan 2015 13:10:34 +0100 Subject: Added RPC "Call" for JS calls to contracts --- javascript/javascript_runtime.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'javascript/javascript_runtime.go') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index c780eb754..398daf43a 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -58,8 +58,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { re.Vm.Run(jsLib) // Load extra javascript files - re.LoadIntFile("string.js") - re.LoadIntFile("big.js") + re.LoadIntFile("bignumber.min.js") // Subscribe to events mux := ethereum.EventMux() -- cgit v1.2.3 From 56f777b2fc77275bc636562b66a08b19afe2ec56 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 5 Feb 2015 03:16:16 +0100 Subject: cmd/ethereum, cmd/mist, core, eth, javascript, xeth: fixes for new p2p API --- javascript/javascript_runtime.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'javascript/javascript_runtime.go') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 398daf43a..a09aff027 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" @@ -201,8 +202,15 @@ func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value { if err != nil { return otto.FalseValue() } - self.ethereum.SuggestPeer(host) - + idstr, err := call.Argument(0).ToString() + if err != nil { + return otto.FalseValue() + } + id, err := discover.HexID(idstr) + if err != nil { + return otto.FalseValue() + } + self.ethereum.SuggestPeer(host, id) return otto.TrueValue() } -- cgit v1.2.3 From 2cf4fed11b01bb99e08b838f7df2b9396f42f758 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 7 Feb 2015 00:15:04 +0100 Subject: cmd/mist, eth, javascript, p2p: use Node URLs for peer suggestions --- javascript/javascript_runtime.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'javascript/javascript_runtime.go') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index a09aff027..0aa0f73e2 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -14,7 +14,6 @@ import ( "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/p2p/discover" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" @@ -198,19 +197,13 @@ func (self *JSRE) watch(call otto.FunctionCall) otto.Value { } func (self *JSRE) addPeer(call otto.FunctionCall) otto.Value { - host, err := call.Argument(0).ToString() + nodeURL, err := call.Argument(0).ToString() if err != nil { return otto.FalseValue() } - idstr, err := call.Argument(0).ToString() - if err != nil { - return otto.FalseValue() - } - id, err := discover.HexID(idstr) - if err != nil { + if err := self.ethereum.SuggestPeer(nodeURL); err != nil { return otto.FalseValue() } - self.ethereum.SuggestPeer(host, id) return otto.TrueValue() } -- cgit v1.2.3