mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-02 06:07:08 +00:00
update everything for Params and Result types
This commit is contained in:
+37
-28
@@ -84,55 +84,64 @@ func NewGRPCApplication(app Application) *GRPCApplication {
|
||||
return &GRPCApplication{app}
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) Echo(ctx context.Context, req *ParamsEcho) (*ResultEcho, error) {
|
||||
return &ResultEcho{req.Message}, nil
|
||||
func (app *GRPCApplication) Echo(ctx context.Context, req *RequestEcho) (*ResponseEcho, error) {
|
||||
return &ResponseEcho{req.Message}, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) Flush(ctx context.Context, req *ParamsFlush) (*ResultFlush, error) {
|
||||
return &ResultFlush{}, nil
|
||||
func (app *GRPCApplication) Flush(ctx context.Context, req *RequestFlush) (*ResponseFlush, error) {
|
||||
return &ResponseFlush{}, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) Info(ctx context.Context, req *ParamsInfo) (*ResultInfo, error) {
|
||||
res := app.app.Info(*req)
|
||||
return &res, nil
|
||||
func (app *GRPCApplication) Info(ctx context.Context, req *RequestInfo) (*ResponseInfo, error) {
|
||||
res := app.app.Info(ToParamsInfo(*req))
|
||||
r := FromResultInfo(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) SetOption(ctx context.Context, req *ParamsSetOption) (*ResultSetOption, error) {
|
||||
res := app.app.SetOption(*req)
|
||||
return &res, nil
|
||||
func (app *GRPCApplication) SetOption(ctx context.Context, req *RequestSetOption) (*ResponseSetOption, error) {
|
||||
res := app.app.SetOption(ToParamsSetOption(*req))
|
||||
r := FromResultSetOption(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) DeliverTx(ctx context.Context, req *ParamsDeliverTx) (*ResultDeliverTx, error) {
|
||||
func (app *GRPCApplication) DeliverTx(ctx context.Context, req *RequestDeliverTx) (*ResponseDeliverTx, error) {
|
||||
res := app.app.DeliverTx(req.Tx)
|
||||
return &res, nil
|
||||
r := FromResultDeliverTx(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) CheckTx(ctx context.Context, req *ParamsCheckTx) (*ResultCheckTx, error) {
|
||||
func (app *GRPCApplication) CheckTx(ctx context.Context, req *RequestCheckTx) (*ResponseCheckTx, error) {
|
||||
res := app.app.CheckTx(req.Tx)
|
||||
return &res, nil
|
||||
r := FromResultCheckTx(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) Query(ctx context.Context, req *ParamsQuery) (*ResultQuery, error) {
|
||||
res := app.app.Query(*req)
|
||||
return &res, nil
|
||||
func (app *GRPCApplication) Query(ctx context.Context, req *RequestQuery) (*ResponseQuery, error) {
|
||||
res := app.app.Query(ToParamsQuery(*req))
|
||||
r := FromResultQuery(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) Commit(ctx context.Context, req *ParamsCommit) (*ResultCommit, error) {
|
||||
func (app *GRPCApplication) Commit(ctx context.Context, req *RequestCommit) (*ResponseCommit, error) {
|
||||
res := app.app.Commit()
|
||||
return &res, nil
|
||||
r := FromResultCommit(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) InitChain(ctx context.Context, req *ParamsInitChain) (*ResultInitChain, error) {
|
||||
res := app.app.InitChain(*req)
|
||||
return &res, nil
|
||||
func (app *GRPCApplication) InitChain(ctx context.Context, req *RequestInitChain) (*ResponseInitChain, error) {
|
||||
res := app.app.InitChain(ToParamsInitChain(*req))
|
||||
r := FromResultInitChain(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) BeginBlock(ctx context.Context, req *ParamsBeginBlock) (*ResultBeginBlock, error) {
|
||||
res := app.app.BeginBlock(*req)
|
||||
return &res, nil
|
||||
func (app *GRPCApplication) BeginBlock(ctx context.Context, req *RequestBeginBlock) (*ResponseBeginBlock, error) {
|
||||
res := app.app.BeginBlock(ToParamsBeginBlock(*req))
|
||||
r := FromResultBeginBlock(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (app *GRPCApplication) EndBlock(ctx context.Context, req *ParamsEndBlock) (*ResultEndBlock, error) {
|
||||
res := app.app.EndBlock(*req)
|
||||
return &res, nil
|
||||
func (app *GRPCApplication) EndBlock(ctx context.Context, req *RequestEndBlock) (*ResponseEndBlock, error) {
|
||||
res := app.app.EndBlock(ToParamsEndBlock(*req))
|
||||
r := FromResultEndBlock(res)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
@@ -33,3 +33,35 @@ func (r ResponseQuery) IsOK() bool {
|
||||
func (r ResponseQuery) IsErr() bool {
|
||||
return r.Code != CodeTypeOK
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
// IsOK returns true if Code is OK.
|
||||
func (r ResultCheckTx) IsOK() bool {
|
||||
return r.Code == CodeTypeOK
|
||||
}
|
||||
|
||||
// IsErr returns true if Code is something other than OK.
|
||||
func (r ResultCheckTx) IsErr() bool {
|
||||
return r.Code != CodeTypeOK
|
||||
}
|
||||
|
||||
// IsOK returns true if Code is OK.
|
||||
func (r ResultDeliverTx) IsOK() bool {
|
||||
return r.Code == CodeTypeOK
|
||||
}
|
||||
|
||||
// IsErr returns true if Code is something other than OK.
|
||||
func (r ResultDeliverTx) IsErr() bool {
|
||||
return r.Code != CodeTypeOK
|
||||
}
|
||||
|
||||
// IsOK returns true if Code is OK.
|
||||
func (r ResultQuery) IsOK() bool {
|
||||
return r.Code == CodeTypeOK
|
||||
}
|
||||
|
||||
// IsErr returns true if Code is something other than OK.
|
||||
func (r ResultQuery) IsErr() bool {
|
||||
return r.Code != CodeTypeOK
|
||||
}
|
||||
|
||||
@@ -11,16 +11,36 @@ type ParamsInfo struct {
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
func ToParamsInfo(req RequestInfo) ParamsInfo {
|
||||
return ParamsInfo{
|
||||
Version: req.Version,
|
||||
}
|
||||
}
|
||||
|
||||
type ParamsSetOption struct {
|
||||
Key string `json:"key,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
func ToParamsSetOption(req RequestSetOption) ParamsSetOption {
|
||||
return ParamsSetOption{
|
||||
Key: req.Key,
|
||||
Value: req.Value,
|
||||
}
|
||||
}
|
||||
|
||||
type ParamsInitChain struct {
|
||||
Validators []Validator `json:"validators"`
|
||||
GenesisBytes []byte `json:"genesis_bytes,omitempty"`
|
||||
}
|
||||
|
||||
func ToParamsInitChain(req RequestInitChain) ParamsInitChain {
|
||||
return ParamsInitChain{
|
||||
Validators: req.Validators,
|
||||
GenesisBytes: req.GenesisBytes,
|
||||
}
|
||||
}
|
||||
|
||||
type ParamsQuery struct {
|
||||
Data []byte `json:"data,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
@@ -28,6 +48,15 @@ type ParamsQuery struct {
|
||||
Prove bool `json:"prove,omitempty"`
|
||||
}
|
||||
|
||||
func ToParamsQuery(req RequestQuery) ParamsQuery {
|
||||
return ParamsQuery{
|
||||
Data: req.Data,
|
||||
Path: req.Path,
|
||||
Height: req.Height,
|
||||
Prove: req.Prove,
|
||||
}
|
||||
}
|
||||
|
||||
type ParamsBeginBlock struct {
|
||||
Hash []byte `json:"hash,omitempty"`
|
||||
Header Header `json:"header"`
|
||||
@@ -35,6 +64,20 @@ type ParamsBeginBlock struct {
|
||||
ByzantineValidators []Evidence `json:"byzantine_validators"`
|
||||
}
|
||||
|
||||
func ToParamsBeginBlock(req RequestBeginBlock) ParamsBeginBlock {
|
||||
vals := make([]SigningValidator, len(req.Validators))
|
||||
for i := 0; i < len(vals); i++ {
|
||||
v := req.Validators[i]
|
||||
vals[i] = *v
|
||||
}
|
||||
return ParamsBeginBlock{
|
||||
Hash: req.Hash,
|
||||
Header: req.Header,
|
||||
Validators: vals,
|
||||
ByzantineValidators: req.ByzantineValidators,
|
||||
}
|
||||
}
|
||||
|
||||
type ParamsCheckTx struct {
|
||||
Tx []byte `json:"tx,omitempty"`
|
||||
}
|
||||
@@ -47,5 +90,11 @@ type ParamsEndBlock struct {
|
||||
Height int64 `json:"height,omitempty"`
|
||||
}
|
||||
|
||||
func ToParamsEndBlock(req RequestEndBlock) ParamsEndBlock {
|
||||
return ParamsEndBlock{
|
||||
Height: req.Height,
|
||||
}
|
||||
}
|
||||
|
||||
type ParamsCommit struct {
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ type ResultInfo struct {
|
||||
LastBlockAppHash []byte `json:"last_block_app_hash,omitempty"`
|
||||
}
|
||||
|
||||
func FromResultInfo(res ResultInfo) ResponseInfo {
|
||||
return ResponseInfo(res)
|
||||
}
|
||||
|
||||
type ResultSetOption struct {
|
||||
Code uint32 `json:"code,omitempty"`
|
||||
// bytes data = 2;
|
||||
@@ -28,10 +32,18 @@ type ResultSetOption struct {
|
||||
Info string `json:"info,omitempty"`
|
||||
}
|
||||
|
||||
func FromResultSetOption(res ResultSetOption) ResponseSetOption {
|
||||
return ResponseSetOption(res)
|
||||
}
|
||||
|
||||
type ResultInitChain struct {
|
||||
Validators []Validator `json:"validators"`
|
||||
}
|
||||
|
||||
func FromResultInitChain(res ResultInitChain) ResponseInitChain {
|
||||
return ResponseInitChain(res)
|
||||
}
|
||||
|
||||
type ResultQuery struct {
|
||||
Code uint32 `json:"code,omitempty"`
|
||||
// bytes data = 2; // use "value" instead.
|
||||
@@ -44,10 +56,18 @@ type ResultQuery struct {
|
||||
Height int64 `json:"height,omitempty"`
|
||||
}
|
||||
|
||||
func FromResultQuery(res ResultQuery) ResponseQuery {
|
||||
return ResponseQuery(res)
|
||||
}
|
||||
|
||||
type ResultBeginBlock struct {
|
||||
Tags []common.KVPair `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func FromResultBeginBlock(res ResultBeginBlock) ResponseBeginBlock {
|
||||
return ResponseBeginBlock(res)
|
||||
}
|
||||
|
||||
type ResultCheckTx struct {
|
||||
Code uint32 `json:"code,omitempty"`
|
||||
Data []byte `json:"data,omitempty"`
|
||||
@@ -59,6 +79,10 @@ type ResultCheckTx struct {
|
||||
Fee common.KI64Pair `json:"fee"`
|
||||
}
|
||||
|
||||
func FromResultCheckTx(res ResultCheckTx) ResponseCheckTx {
|
||||
return ResponseCheckTx(res)
|
||||
}
|
||||
|
||||
type ResultDeliverTx struct {
|
||||
Code uint32 `json:"code,omitempty"`
|
||||
Data []byte `json:"data,omitempty"`
|
||||
@@ -70,13 +94,25 @@ type ResultDeliverTx struct {
|
||||
Fee common.KI64Pair `json:"fee"`
|
||||
}
|
||||
|
||||
func FromResultDeliverTx(res ResultDeliverTx) ResponseDeliverTx {
|
||||
return ResponseDeliverTx(res)
|
||||
}
|
||||
|
||||
type ResultEndBlock struct {
|
||||
ValidatorUpdates []Validator `json:"validator_updates"`
|
||||
ConsensusParamUpdates *ConsensusParams `json:"consensus_param_updates,omitempty"`
|
||||
Tags []common.KVPair `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
func FromResultEndBlock(res ResultEndBlock) ResponseEndBlock {
|
||||
return ResponseEndBlock(res)
|
||||
}
|
||||
|
||||
type ResultCommit struct {
|
||||
// reserve 1
|
||||
Data []byte `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func FromResultCommit(res ResultCommit) ResponseCommit {
|
||||
return ResponseCommit(res)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user