Beispiel #1
0
func (cli *grpcClient) AppendTxAsync(tx []byte) *ReqRes {
	req := types.ToRequestAppendTx(tx)
	res, err := cli.client.AppendTx(context.Background(), req.GetAppendTx(), grpc.FailFast(true))
	if err != nil {
		cli.StopForError(err)
	}
	return cli.finishAsyncCall(req, &types.Response{&types.Response_AppendTx{res}})
}
Beispiel #2
0
func (cli *socketClient) AppendTxSync(tx []byte) (res types.Result) {
	reqres := cli.queueRequest(types.ToRequestAppendTx(tx))
	cli.FlushSync()
	if err := cli.Error(); err != nil {
		return types.ErrInternalError.SetLog(err.Error())
	}
	resp := reqres.Response.GetAppendTx()
	return types.Result{Code: resp.Code, Data: resp.Data, Log: resp.Log}
}
Beispiel #3
0
func (app *localClient) AppendTxAsync(tx []byte) *ReqRes {
	app.mtx.Lock()
	res := app.Application.AppendTx(tx)
	app.mtx.Unlock()
	return app.callback(
		types.ToRequestAppendTx(tx),
		types.ToResponseAppendTx(res.Code, res.Data, res.Log),
	)
}
Beispiel #4
0
func (cli *socketClient) AppendTxAsync(tx []byte) *ReqRes {
	return cli.queueRequest(types.ToRequestAppendTx(tx))
}