From 0aea5fc4a3ed9c08272d3a894c0a31212dc25a7a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 14 Oct 2014 19:38:38 +0200 Subject: adapt to new event package --- javascript/javascript_runtime.go | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index ffc672a63..16e22964f 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -11,9 +11,9 @@ import ( "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethpipe" - "github.com/ethereum/eth-go/ethreact" "github.com/ethereum/eth-go/ethstate" "github.com/ethereum/eth-go/ethutil" + "github.com/ethereum/eth-go/event" "github.com/ethereum/go-ethereum/utils" "github.com/obscuren/otto" ) @@ -25,9 +25,8 @@ type JSRE struct { Vm *otto.Otto pipe *ethpipe.JSPipe - blockChan chan ethreact.Event - changeChan chan ethreact.Event - quitChan chan bool + events event.Subscription + quitChan chan bool objectCb map[string][]otto.Value } @@ -51,8 +50,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { ethereum, otto.New(), ethpipe.NewJSPipe(ethereum), - make(chan ethreact.Event, 10), - make(chan ethreact.Event, 10), + nil, make(chan bool), make(map[string][]otto.Value), } @@ -68,8 +66,8 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { go re.mainLoop() // Subscribe to events - reactor := ethereum.Reactor() - reactor.Subscribe("newBlock", re.blockChan) + mux := ethereum.EventMux() + re.events = mux.Subscribe(ethchain.NewBlockEvent{}) re.Bind("eth", &JSEthereum{re.pipe, re.Vm, ethereum}) @@ -105,25 +103,16 @@ func (self *JSRE) Require(file string) error { } func (self *JSRE) Stop() { + self.events.Unsubscribe() // Kill the main loop self.quitChan <- true - close(self.blockChan) close(self.quitChan) - close(self.changeChan) jsrelogger.Infoln("stopped") } func (self *JSRE) mainLoop() { -out: - for { - select { - case <-self.quitChan: - break out - case block := <-self.blockChan: - if _, ok := block.Resource.(*ethchain.Block); ok { - } - } + for _ = range self.events.Chan() { } } @@ -201,13 +190,13 @@ func (self *JSRE) watch(call otto.FunctionCall) otto.Value { if storageCallback { self.objectCb[addr+storageAddr] = append(self.objectCb[addr+storageAddr], cb) - event := "storage:" + string(ethutil.Hex2Bytes(addr)) + ":" + string(ethutil.Hex2Bytes(storageAddr)) - self.ethereum.Reactor().Subscribe(event, self.changeChan) + // event := "storage:" + string(ethutil.Hex2Bytes(addr)) + ":" + string(ethutil.Hex2Bytes(storageAddr)) + // self.ethereum.EventMux().Subscribe(event, self.changeChan) } else { self.objectCb[addr] = append(self.objectCb[addr], cb) - event := "object:" + string(ethutil.Hex2Bytes(addr)) - self.ethereum.Reactor().Subscribe(event, self.changeChan) + // event := "object:" + string(ethutil.Hex2Bytes(addr)) + // self.ethereum.EventMux().Subscribe(event, self.changeChan) } return otto.UndefinedValue() -- cgit v1.2.3 From 7227552f429e6ad035b22167d667712e61fcebbb Mon Sep 17 00:00:00 2001 From: Erez Wanderman Date: Wed, 15 Oct 2014 02:41:26 +0300 Subject: Fix ethereum compilation and functioning on Windows. repl console output is now colored. repl "exit" command now works. --- javascript/js_lib.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/js_lib.go b/javascript/js_lib.go index a3e9b8a5b..dd1fe5f4d 100644 --- a/javascript/js_lib.go +++ b/javascript/js_lib.go @@ -44,9 +44,11 @@ function pp(object) { function prettyPrint(/* */) { var args = arguments; + var ret = ""; for(var i = 0, l = args.length; i < l; i++) { - console.log(pp(args[i])) + ret += pp(args[i]) + "\n"; } + return ret; } var print = prettyPrint; -- cgit v1.2.3 From 77badc8c4603674c5fd587150de104e553fce71f Mon Sep 17 00:00:00 2001 From: obscuren Date: Sat, 18 Oct 2014 13:20:35 +0200 Subject: Updated to reflect the Filter changes in eth-go --- javascript/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'javascript') diff --git a/javascript/types.go b/javascript/types.go index 53a2977a8..560960f54 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -4,10 +4,10 @@ import ( "fmt" "github.com/ethereum/eth-go" - "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethpipe" "github.com/ethereum/eth-go/ethstate" "github.com/ethereum/eth-go/ethutil" + "github.com/ethereum/eth-go/ui" "github.com/obscuren/otto" ) @@ -128,7 +128,7 @@ func (self *JSEthereum) toVal(v interface{}) otto.Value { } func (self *JSEthereum) Messages(object map[string]interface{}) otto.Value { - filter := ethchain.NewFilterFromMap(object, self.ethereum) + filter := ui.NewFilterFromMap(object, self.ethereum) messages := filter.Find() var msgs []JSMessage -- cgit v1.2.3 From 6ea44c466a5c3383dd4e21a57423edbf33a52e6f Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 20 Oct 2014 12:03:31 +0200 Subject: Updated to reflect BlockChain changes --- javascript/javascript_runtime.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 16e22964f..189106ae9 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -139,10 +139,10 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { var block *ethchain.Block if call.Argument(0).IsNumber() { num, _ := call.Argument(0).ToInteger() - block = self.ethereum.BlockChain().GetBlockByNumber(uint64(num)) + block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num)) } else if call.Argument(0).IsString() { hash, _ := call.Argument(0).ToString() - block = self.ethereum.BlockChain().GetBlock(ethutil.Hex2Bytes(hash)) + block = self.ethereum.ChainManager().GetBlock(ethutil.Hex2Bytes(hash)) } else { fmt.Println("invalid argument for dump. Either hex string or number") } -- cgit v1.2.3 From b095bd32371f02d204a4d0fbde75dc58baa7430d Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 27 Oct 2014 11:50:38 +0100 Subject: events should be set prior to calling mainloop --- javascript/javascript_runtime.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index b0d7c81b5..704635d97 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -41,7 +41,7 @@ func (jsre *JSRE) LoadExtFile(path string) { } func (jsre *JSRE) LoadIntFile(file string) { - assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "mist", "assets", "ext") + assetPath := path.Join(os.Getenv("GOPATH"), "src", "github.com", "ethereum", "go-ethereum", "cmd", "mist", "assets", "ext") jsre.LoadExtFile(path.Join(assetPath, file)) } @@ -62,13 +62,13 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { re.LoadIntFile("string.js") re.LoadIntFile("big.js") - // We have to make sure that, whoever calls this, calls "Stop" - go re.mainLoop() - // Subscribe to events mux := ethereum.EventMux() re.events = mux.Subscribe(ethchain.NewBlockEvent{}) + // We have to make sure that, whoever calls this, calls "Stop" + go re.mainLoop() + re.Bind("eth", &JSEthereum{re.pipe, re.Vm, ethereum}) re.initStdFuncs() -- cgit v1.2.3 From 8170f96dedb983c391d26378726d7fd6921ff959 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 29 Oct 2014 03:00:29 +0100 Subject: javascript: remove unused quit channel This fixes the hang in JSRE.Stop. --- javascript/javascript_runtime.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 704635d97..6c5a87338 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -25,8 +25,7 @@ type JSRE struct { Vm *otto.Otto pipe *ethpipe.JSPipe - events event.Subscription - quitChan chan bool + events event.Subscription objectCb map[string][]otto.Value } @@ -51,7 +50,6 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { otto.New(), ethpipe.NewJSPipe(ethereum), nil, - make(chan bool), make(map[string][]otto.Value), } @@ -104,10 +102,6 @@ func (self *JSRE) Require(file string) error { func (self *JSRE) Stop() { self.events.Unsubscribe() - // Kill the main loop - self.quitChan <- true - - close(self.quitChan) jsrelogger.Infoln("stopped") } -- cgit v1.2.3 From 3ee0461cb5b6e4a5e2d287180afbdb681805a662 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 31 Oct 2014 10:59:17 +0100 Subject: Moved ethchain to chain --- javascript/javascript_runtime.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 6c5a87338..36850021d 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -8,7 +8,7 @@ import ( "path/filepath" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/ethchain" + "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" @@ -62,7 +62,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { // Subscribe to events mux := ethereum.EventMux() - re.events = mux.Subscribe(ethchain.NewBlockEvent{}) + re.events = mux.Subscribe(chain.NewBlockEvent{}) // We have to make sure that, whoever calls this, calls "Stop" go re.mainLoop() @@ -130,7 +130,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { var state *ethstate.State if len(call.ArgumentList) > 0 { - var block *ethchain.Block + var block *chain.Block if call.Argument(0).IsNumber() { num, _ := call.Argument(0).ToInteger() block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num)) -- cgit v1.2.3 From b1c247231b11f313ca0eedff75ea563926d23f68 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 31 Oct 2014 12:56:05 +0100 Subject: ethlog => logger --- javascript/javascript_runtime.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 36850021d..c539c4348 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -9,16 +9,16 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/chain" - "github.com/ethereum/go-ethereum/ethlog" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/utils" "github.com/obscuren/otto" ) -var jsrelogger = ethlog.NewLogger("JSRE") +var jsrelogger = logger.NewLogger("JSRE") type JSRE struct { ethereum *eth.Ethereum -- cgit v1.2.3 From 8826e9694c3a8d4f480f0a021d8c02f7f61612c6 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 31 Oct 2014 14:20:11 +0100 Subject: Moved utils to cmd --- javascript/javascript_runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index c539c4348..deb6fe305 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -9,12 +9,12 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/chain" + "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/utils" "github.com/obscuren/otto" ) -- cgit v1.2.3 From 0ed1a8b50a9b9726cd57a2731d0405f6949c6188 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 31 Oct 2014 14:30:08 +0100 Subject: ethpipe => xeth (eXtended ETHereum) --- javascript/javascript_runtime.go | 6 +++--- javascript/types.go | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index deb6fe305..5885e5c6e 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -10,11 +10,11 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/cmd/utils" - "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" ) @@ -23,7 +23,7 @@ var jsrelogger = logger.NewLogger("JSRE") type JSRE struct { ethereum *eth.Ethereum Vm *otto.Otto - pipe *ethpipe.JSPipe + pipe *xeth.JSXEth events event.Subscription @@ -48,7 +48,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { re := &JSRE{ ethereum, otto.New(), - ethpipe.NewJSPipe(ethereum), + xeth.NewJSXEth(ethereum), nil, make(map[string][]otto.Value), } diff --git a/javascript/types.go b/javascript/types.go index b02ee9dc2..a98c48905 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -4,15 +4,15 @@ import ( "fmt" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/ethpipe" "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ui" + "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" ) type JSStateObject struct { - *ethpipe.JSObject + *xeth.JSObject eth *JSEthereum } @@ -30,7 +30,7 @@ func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value { // The JSEthereum object attempts to wrap the PEthereum object and returns // meaningful javascript objects type JSBlock struct { - *ethpipe.JSBlock + *xeth.JSBlock eth *JSEthereum } @@ -67,33 +67,33 @@ func NewJSMessage(message *ethstate.Message) JSMessage { } type JSEthereum struct { - *ethpipe.JSPipe + *xeth.JSXEth vm *otto.Otto ethereum *eth.Ethereum } func (self *JSEthereum) GetBlock(hash string) otto.Value { - return self.toVal(&JSBlock{self.JSPipe.BlockByHash(hash), self}) + return self.toVal(&JSBlock{self.JSXEth.BlockByHash(hash), self}) } func (self *JSEthereum) GetPeers() otto.Value { - return self.toVal(self.JSPipe.Peers()) + return self.toVal(self.JSXEth.Peers()) } func (self *JSEthereum) GetKey() otto.Value { - return self.toVal(self.JSPipe.Key()) + return self.toVal(self.JSXEth.Key()) } func (self *JSEthereum) GetStateObject(addr string) otto.Value { - return self.toVal(&JSStateObject{ethpipe.NewJSObject(self.JSPipe.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.JSPipe.Peers()) + return self.toVal(self.JSXEth.Peers()) } func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value { - r, err := self.JSPipe.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) + r, err := self.JSXEth.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) if err != nil { fmt.Println(err) @@ -104,7 +104,7 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, } func (self *JSEthereum) Create(key, valueStr, gasStr, gasPriceStr, scriptStr string) otto.Value { - r, err := self.JSPipe.Transact(key, "", valueStr, gasStr, gasPriceStr, scriptStr) + r, err := self.JSXEth.Transact(key, "", valueStr, gasStr, gasPriceStr, scriptStr) if err != nil { fmt.Println(err) -- cgit v1.2.3 From af8f5f0b69f1c359991d12c7708804fe8dd1f944 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 31 Oct 2014 14:43:14 +0100 Subject: ethstate => state --- javascript/javascript_runtime.go | 4 ++-- javascript/types.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 5885e5c6e..ea3cb6071 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -10,10 +10,10 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/chain" "github.com/ethereum/go-ethereum/cmd/utils" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" ) @@ -127,7 +127,7 @@ func (self *JSRE) initStdFuncs() { */ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { - var state *ethstate.State + var state *state.State if len(call.ArgumentList) > 0 { var block *chain.Block diff --git a/javascript/types.go b/javascript/types.go index a98c48905..d5acaecce 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/ethstate" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/ui" "github.com/ethereum/go-ethereum/xeth" "github.com/obscuren/otto" @@ -51,7 +51,7 @@ type JSMessage struct { Number int32 `json:"number"` } -func NewJSMessage(message *ethstate.Message) JSMessage { +func NewJSMessage(message *state.Message) JSMessage { return JSMessage{ To: ethutil.Bytes2Hex(message.To), From: ethutil.Bytes2Hex(message.From), -- cgit v1.2.3 From f59a3b67f69b26f969084e0de165435e80bd8e12 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 4 Nov 2014 10:57:02 +0100 Subject: StateManager => BlockManager --- javascript/javascript_runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index ea3cb6071..86a376fbf 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -149,7 +149,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { state = block.State() } else { - state = self.ethereum.StateManager().CurrentState() + state = self.ethereum.BlockManager().CurrentState() } v, _ := self.Vm.ToValue(state.Dump()) -- cgit v1.2.3 From a1b6a9ac29d0aa8d29a2c0535bafdb5fe4d4830b Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 18 Nov 2014 16:58:22 +0100 Subject: Begin of moving objects to types package * Block(s) * Transaction(s) --- javascript/javascript_runtime.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 86a376fbf..e8b785f50 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/chain" + "github.com/ethereum/go-ethereum/chain/types" "github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event" @@ -130,7 +131,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { var state *state.State if len(call.ArgumentList) > 0 { - var block *chain.Block + var block *types.Block if call.Argument(0).IsNumber() { num, _ := call.Argument(0).ToInteger() block = self.ethereum.ChainManager().GetBlockByNumber(uint64(num)) -- cgit v1.2.3 From 9008b155d3c8d2a32c4c8945f1174243d48d4e90 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 4 Dec 2014 10:28:02 +0100 Subject: Renamed `chain` => `core` --- javascript/javascript_runtime.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index e8b785f50..0aa376a0a 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -8,9 +8,9 @@ import ( "path/filepath" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/chain" - "github.com/ethereum/go-ethereum/chain/types" "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/ethutil" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" @@ -63,7 +63,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { // Subscribe to events mux := ethereum.EventMux() - re.events = mux.Subscribe(chain.NewBlockEvent{}) + re.events = mux.Subscribe(core.NewBlockEvent{}) // We have to make sure that, whoever calls this, calls "Stop" go re.mainLoop() -- cgit v1.2.3 From f298ffdbb8ec2b14f254e880a65f22f4d7c66305 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 4 Dec 2014 11:40:20 +0100 Subject: Renamed State => StateDB --- javascript/javascript_runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 0aa376a0a..a5b929a34 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -128,7 +128,7 @@ func (self *JSRE) initStdFuncs() { */ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { - var state *state.State + var state *state.StateDB if len(call.ArgumentList) > 0 { var block *types.Block -- cgit v1.2.3 From 5553e5aaed5c3f4e303b7d6671d2c92a45aa487e Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 10 Dec 2014 19:59:12 +0100 Subject: states moved to chain --- javascript/javascript_runtime.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index a5b929a34..84d61d405 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -150,7 +150,7 @@ func (self *JSRE) dump(call otto.FunctionCall) otto.Value { state = block.State() } else { - state = self.ethereum.BlockManager().CurrentState() + state = self.ethereum.ChainManager().State() } v, _ := self.Vm.ToValue(state.Dump()) -- cgit v1.2.3 From b1c58b76a9588a90db5a773a997bb70265c378d3 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 17 Dec 2014 12:57:35 +0100 Subject: moved err check --- javascript/javascript_runtime.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'javascript') diff --git a/javascript/javascript_runtime.go b/javascript/javascript_runtime.go index 84d61d405..a26f0154e 100644 --- a/javascript/javascript_runtime.go +++ b/javascript/javascript_runtime.go @@ -121,6 +121,7 @@ func (self *JSRE) initStdFuncs() { eth.Set("startMining", self.startMining) eth.Set("execBlock", self.execBlock) eth.Set("dump", self.dump) + eth.Set("export", self.export) } /* @@ -236,3 +237,20 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value { return otto.TrueValue() } + +func (self *JSRE) export(call otto.FunctionCall) otto.Value { + fn, err := call.Argument(0).ToString() + if err != nil { + fmt.Println(err) + return otto.FalseValue() + } + + data := self.ethereum.ChainManager().Export() + + if err := ethutil.WriteFile(fn, data); err != nil { + fmt.Println(err) + return otto.FalseValue() + } + + return otto.TrueValue() +} -- cgit v1.2.3