Пример #1
0
func NewJSRE(ethereum *eth.Ethereum) *JSRE {
	re := &JSRE{
		ethereum,
		otto.New(),
		ethpub.NewPEthereum(ethereum),
		make(chan ethutil.React, 1),
		make(chan ethutil.React, 1),
		make(chan bool),
		make(map[string][]otto.Value),
	}

	// Init the JS lib
	re.vm.Run(jsLib)

	// Load extra javascript files
	re.LoadIntFile("string.js")
	re.LoadIntFile("big.js")

	// We have to make sure that, whoever calls this, calls "Stop"
	go re.mainLoop()

	re.Bind("eth", &JSEthereum{re.lib, re.vm})

	re.initStdFuncs()

	jsrelogger.Infoln("started")

	return re
}
func NewJSRE(ethereum *eth.Ethereum) *JSRE {
	re := &JSRE{
		ethereum,
		otto.New(),
		ethpipe.NewJSPipe(ethereum),
		make(chan ethreact.Event, 10),
		make(chan ethreact.Event, 10),
		make(chan bool),
		make(map[string][]otto.Value),
	}

	// Init the JS lib
	re.Vm.Run(jsLib)

	// Load extra javascript files
	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
	reactor := ethereum.Reactor()
	reactor.Subscribe("newBlock", re.blockChan)

	re.Bind("eth", &JSEthereum{re.pipe, re.Vm, ethereum})

	re.initStdFuncs()

	jsrelogger.Infoln("started")

	return re
}