diff options
author | zelig <viktor.tron@gmail.com> | 2014-07-15 08:13:39 +0800 |
---|---|---|
committer | zelig <viktor.tron@gmail.com> | 2014-07-15 08:13:39 +0800 |
commit | 75a7a4c97c350e911f4d721e940a59c0740ae967 (patch) | |
tree | f58ff56c3682da4e8548ff9f331c9ac351a94bf4 /ethereum/javascript_runtime.go | |
parent | 94b12f7804bfb32763c9bbbce323af5d84c74910 (diff) | |
download | dexon-75a7a4c97c350e911f4d721e940a59c0740ae967.tar.gz dexon-75a7a4c97c350e911f4d721e940a59c0740ae967.tar.zst dexon-75a7a4c97c350e911f4d721e940a59c0740ae967.zip |
ethreact
- use ethreact.Event,
- increased buffered event channels,
- subscribe after loop reading from channel starts
Diffstat (limited to 'ethereum/javascript_runtime.go')
-rw-r--r-- | ethereum/javascript_runtime.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ethereum/javascript_runtime.go b/ethereum/javascript_runtime.go index 852a50487..998ff7520 100644 --- a/ethereum/javascript_runtime.go +++ b/ethereum/javascript_runtime.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethpub" + "github.com/ethereum/eth-go/ethreact" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/go-ethereum/utils" "github.com/obscuren/otto" @@ -22,8 +23,8 @@ type JSRE struct { vm *otto.Otto lib *ethpub.PEthereum - blockChan chan ethutil.React - changeChan chan ethutil.React + blockChan chan ethreact.Event + changeChan chan ethreact.Event quitChan chan bool objectCb map[string][]otto.Value @@ -48,8 +49,8 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { ethereum, otto.New(), ethpub.NewPEthereum(ethereum), - make(chan ethutil.React, 1), - make(chan ethutil.React, 1), + make(chan ethreact.Event, 10), + make(chan ethreact.Event, 10), make(chan bool), make(map[string][]otto.Value), } @@ -64,6 +65,10 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE { // We have to make sure that, whoever calls this, calls "Stop" go re.mainLoop() + // Subscribe to events + reactor := ethereum.Reactor() + reactor.Subscribe("newBlock", self.blockChan) + re.Bind("eth", &JSEthereum{re.lib, re.vm}) re.initStdFuncs() @@ -108,10 +113,6 @@ func (self *JSRE) Stop() { } func (self *JSRE) mainLoop() { - // Subscribe to events - reactor := self.ethereum.Reactor() - reactor.Subscribe("newBlock", self.blockChan) - out: for { select { |