コード例 #1
0
ファイル: local_client.go プロジェクト: tendermint/tmsp
func (app *localClient) InfoAsync() *ReqRes {
	app.mtx.Lock()
	info := app.Application.Info()
	app.mtx.Unlock()
	return app.callback(
		types.ToRequestInfo(),
		types.ToResponseInfo(info),
	)
}
コード例 #2
0
ファイル: socket_server.go プロジェクト: tendermint/tmsp
func (s *SocketServer) handleRequest(req *types.Request, responses chan<- *types.Response) {
	switch r := req.Value.(type) {
	case *types.Request_Echo:
		responses <- types.ToResponseEcho(r.Echo.Message)
	case *types.Request_Flush:
		responses <- types.ToResponseFlush()
	case *types.Request_Info:
		data := s.app.Info()
		responses <- types.ToResponseInfo(data)
	case *types.Request_SetOption:
		so := r.SetOption
		logStr := s.app.SetOption(so.Key, so.Value)
		responses <- types.ToResponseSetOption(logStr)
	case *types.Request_AppendTx:
		res := s.app.AppendTx(r.AppendTx.Tx)
		responses <- types.ToResponseAppendTx(res.Code, res.Data, res.Log)
	case *types.Request_CheckTx:
		res := s.app.CheckTx(r.CheckTx.Tx)
		responses <- types.ToResponseCheckTx(res.Code, res.Data, res.Log)
	case *types.Request_Commit:
		res := s.app.Commit()
		responses <- types.ToResponseCommit(res.Code, res.Data, res.Log)
	case *types.Request_Query:
		res := s.app.Query(r.Query.Query)
		responses <- types.ToResponseQuery(res.Code, res.Data, res.Log)
	case *types.Request_InitChain:
		if app, ok := s.app.(types.BlockchainAware); ok {
			app.InitChain(r.InitChain.Validators)
			responses <- types.ToResponseInitChain()
		} else {
			responses <- types.ToResponseInitChain()
		}
	case *types.Request_EndBlock:
		if app, ok := s.app.(types.BlockchainAware); ok {
			validators := app.EndBlock(r.EndBlock.Height)
			responses <- types.ToResponseEndBlock(validators)
		} else {
			responses <- types.ToResponseEndBlock(nil)
		}
	default:
		responses <- types.ToResponseException("Unknown request")
	}
}