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
}
Example #2
0
func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
	var err error
	ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpipe.NewJSPipe(ethereum), RpcPort)
	if err != nil {
		logger.Errorf("Could not start RPC interface (port %v): %v", RpcPort, err)
	} else {
		go ethereum.RpcServer.Start()
	}
}
Example #3
0
func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
	app := &ExtApplication{
		ethpipe.NewJSPipe(lib.eth),
		lib.eth,
		make(chan ethreact.Event, 100),
		make(chan ethreact.Event, 100),
		make(chan bool),
		make(chan bool),
		make(map[string]*ethchain.Filter),
		container,
		lib,
	}

	return app
}
Example #4
0
// Create GUI, but doesn't start it
func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIdentity *ethwire.SimpleClientIdentity, session string, logLevel int) *Gui {
	db, err := ethdb.NewLDBDatabase("tx_database")
	if err != nil {
		panic(err)
	}

	pipe := ethpipe.NewJSPipe(ethereum)
	gui := &Gui{eth: ethereum, txDb: db, pipe: pipe, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config, plugins: make(map[string]plugin)}
	data, err := ethutil.ReadAllFile(ethutil.Config.ExecPath + "/plugins.json")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println("plugins:", string(data))

	json.Unmarshal([]byte(data), &gui.plugins)

	return gui
}
Example #5
0
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
	return &UiLib{JSPipe: ethpipe.NewJSPipe(eth), engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(eth), filterCallbacks: make(map[int][]int), filters: make(map[int]*GuiFilter)}
}