예제 #1
0
파일: node.go 프로젝트: eris-ltd/tendermint
func (n *Node) StartRPC() ([]net.Listener, error) {
	rpccore.SetBlockStore(n.blockStore)
	rpccore.SetConsensusState(n.consensusState)
	rpccore.SetConsensusReactor(n.consensusReactor)
	rpccore.SetMempoolReactor(n.mempoolReactor)
	rpccore.SetSwitch(n.sw)
	rpccore.SetPrivValidator(n.privValidator)
	rpccore.SetGenesisDoc(n.genesisDoc)

	listenAddrs := strings.Split(n.config.GetString("rpc_laddr"), ",")

	// we may expose the rpc over both a unix and tcp socket
	listeners := make([]net.Listener, len(listenAddrs))
	for i, listenAddr := range listenAddrs {
		mux := http.NewServeMux()
		wm := rpcserver.NewWebsocketManager(rpccore.Routes, n.evsw)
		mux.HandleFunc("/websocket", wm.WebsocketHandler)
		rpcserver.RegisterRPCFuncs(mux, rpccore.Routes)
		listener, err := rpcserver.StartHTTPServer(listenAddr, mux)
		if err != nil {
			return nil, err
		}
		listeners[i] = listener
	}
	return listeners, nil
}
예제 #2
0
파일: node.go 프로젝트: jaekwon/GuppyCamp
func (n *Node) StartRPC() {
	core.SetBlockStore(n.blockStore)
	core.SetConsensusState(n.consensusState)
	core.SetConsensusReactor(n.consensusReactor)
	core.SetMempoolReactor(n.mempoolReactor)
	core.SetSwitch(n.sw)
	core.SetPrivValidator(n.privValidator)

	listenAddr := config.GetString("rpc_laddr")
	mux := http.NewServeMux()
	rpcserver.RegisterEventsHandler(mux, n.evsw)
	rpcserver.RegisterRPCFuncs(mux, core.Routes)
	rpcserver.StartHTTPServer(listenAddr, mux)
}
예제 #3
0
func (n *Node) StartRPC() (net.Listener, error) {
	core.SetBlockStore(n.blockStore)
	core.SetConsensusState(n.consensusState)
	core.SetConsensusReactor(n.consensusReactor)
	core.SetMempoolReactor(n.mempoolReactor)
	core.SetSwitch(n.sw)
	core.SetPrivValidator(n.privValidator)
	core.SetGenesisDoc(n.genesisDoc)

	listenAddr := config.GetString("rpc_laddr")

	mux := http.NewServeMux()
	wm := rpcserver.NewWebsocketManager(core.Routes, n.evsw)
	mux.HandleFunc("/websocket", wm.WebsocketHandler)
	rpcserver.RegisterRPCFuncs(mux, core.Routes)
	return rpcserver.StartHTTPServer(listenAddr, mux)
}