Skip to content

Commit

Permalink
Move and adapt supporting code alongside *.pb.go
Browse files Browse the repository at this point in the history
Two types of changes here:
- Adapted manually-written files adding methods to generated Go types.
- Added aliases for multi-versioned type definitions in their
  "parent" domain package that gets the importer the latest definition
   of each message type in the domain.
  • Loading branch information
mzabaluev committed Apr 6, 2023
1 parent 784f976 commit 5a5beff
Show file tree
Hide file tree
Showing 25 changed files with 664 additions and 139 deletions.
67 changes: 34 additions & 33 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/cosmos/gogoproto/proto"

v3 "github.com/cometbft/cometbft/api/cometbft/abci/v3"
"github.com/cometbft/cometbft/libs/protoio"
)

Expand All @@ -29,200 +30,200 @@ func ReadMessage(r io.Reader, msg proto.Message) error {

func ToRequestEcho(message string) *Request {
return &Request{
Value: &Request_Echo{&RequestEcho{Message: message}},
Value: &v3.Request_Echo{&RequestEcho{Message: message}},
}
}

func ToRequestFlush() *Request {
return &Request{
Value: &Request_Flush{&RequestFlush{}},
Value: &v3.Request_Flush{&RequestFlush{}},
}
}

func ToRequestInfo(req *RequestInfo) *Request {
return &Request{
Value: &Request_Info{req},
Value: &v3.Request_Info{req},
}
}

func ToRequestCheckTx(req *RequestCheckTx) *Request {
return &Request{
Value: &Request_CheckTx{req},
Value: &v3.Request_CheckTx{req},
}
}

func ToRequestCommit() *Request {
return &Request{
Value: &Request_Commit{&RequestCommit{}},
Value: &v3.Request_Commit{&RequestCommit{}},
}
}

func ToRequestQuery(req *RequestQuery) *Request {
return &Request{
Value: &Request_Query{req},
Value: &v3.Request_Query{req},
}
}

func ToRequestInitChain(req *RequestInitChain) *Request {
return &Request{
Value: &Request_InitChain{req},
Value: &v3.Request_InitChain{req},
}
}

func ToRequestListSnapshots(req *RequestListSnapshots) *Request {
return &Request{
Value: &Request_ListSnapshots{req},
Value: &v3.Request_ListSnapshots{req},
}
}

func ToRequestOfferSnapshot(req *RequestOfferSnapshot) *Request {
return &Request{
Value: &Request_OfferSnapshot{req},
Value: &v3.Request_OfferSnapshot{req},
}
}

func ToRequestLoadSnapshotChunk(req *RequestLoadSnapshotChunk) *Request {
return &Request{
Value: &Request_LoadSnapshotChunk{req},
Value: &v3.Request_LoadSnapshotChunk{req},
}
}

func ToRequestApplySnapshotChunk(req *RequestApplySnapshotChunk) *Request {
return &Request{
Value: &Request_ApplySnapshotChunk{req},
Value: &v3.Request_ApplySnapshotChunk{req},
}
}

func ToRequestPrepareProposal(req *RequestPrepareProposal) *Request {
return &Request{
Value: &Request_PrepareProposal{req},
Value: &v3.Request_PrepareProposal{req},
}
}

func ToRequestProcessProposal(req *RequestProcessProposal) *Request {
return &Request{
Value: &Request_ProcessProposal{req},
Value: &v3.Request_ProcessProposal{req},
}
}

func ToRequestExtendVote(req *RequestExtendVote) *Request {
return &Request{
Value: &Request_ExtendVote{req},
Value: &v3.Request_ExtendVote{req},
}
}

func ToRequestVerifyVoteExtension(req *RequestVerifyVoteExtension) *Request {
return &Request{
Value: &Request_VerifyVoteExtension{req},
Value: &v3.Request_VerifyVoteExtension{req},
}
}

func ToRequestFinalizeBlock(req *RequestFinalizeBlock) *Request {
return &Request{
Value: &Request_FinalizeBlock{req},
Value: &v3.Request_FinalizeBlock{req},
}
}

//----------------------------------------

func ToResponseException(errStr string) *Response {
return &Response{
Value: &Response_Exception{&ResponseException{Error: errStr}},
Value: &v3.Response_Exception{&ResponseException{Error: errStr}},
}
}

func ToResponseEcho(message string) *Response {
return &Response{
Value: &Response_Echo{&ResponseEcho{Message: message}},
Value: &v3.Response_Echo{&ResponseEcho{Message: message}},
}
}

func ToResponseFlush() *Response {
return &Response{
Value: &Response_Flush{&ResponseFlush{}},
Value: &v3.Response_Flush{&ResponseFlush{}},
}
}

func ToResponseInfo(res *ResponseInfo) *Response {
return &Response{
Value: &Response_Info{res},
Value: &v3.Response_Info{res},
}
}

func ToResponseCheckTx(res *ResponseCheckTx) *Response {
return &Response{
Value: &Response_CheckTx{res},
Value: &v3.Response_CheckTx{res},
}
}

func ToResponseCommit(res *ResponseCommit) *Response {
return &Response{
Value: &Response_Commit{res},
Value: &v3.Response_Commit{res},
}
}

func ToResponseQuery(res *ResponseQuery) *Response {
return &Response{
Value: &Response_Query{res},
Value: &v3.Response_Query{res},
}
}

func ToResponseInitChain(res *ResponseInitChain) *Response {
return &Response{
Value: &Response_InitChain{res},
Value: &v3.Response_InitChain{res},
}
}

func ToResponseListSnapshots(res *ResponseListSnapshots) *Response {
return &Response{
Value: &Response_ListSnapshots{res},
Value: &v3.Response_ListSnapshots{res},
}
}

func ToResponseOfferSnapshot(res *ResponseOfferSnapshot) *Response {
return &Response{
Value: &Response_OfferSnapshot{res},
Value: &v3.Response_OfferSnapshot{res},
}
}

func ToResponseLoadSnapshotChunk(res *ResponseLoadSnapshotChunk) *Response {
return &Response{
Value: &Response_LoadSnapshotChunk{res},
Value: &v3.Response_LoadSnapshotChunk{res},
}
}

func ToResponseApplySnapshotChunk(res *ResponseApplySnapshotChunk) *Response {
return &Response{
Value: &Response_ApplySnapshotChunk{res},
Value: &v3.Response_ApplySnapshotChunk{res},
}
}

func ToResponsePrepareProposal(res *ResponsePrepareProposal) *Response {
return &Response{
Value: &Response_PrepareProposal{res},
Value: &v3.Response_PrepareProposal{res},
}
}

func ToResponseProcessProposal(res *ResponseProcessProposal) *Response {
return &Response{
Value: &Response_ProcessProposal{res},
Value: &v3.Response_ProcessProposal{res},
}
}

func ToResponseExtendVote(res *ResponseExtendVote) *Response {
return &Response{
Value: &Response_ExtendVote{res},
Value: &v3.Response_ExtendVote{res},
}
}

func ToResponseVerifyVoteExtension(res *ResponseVerifyVoteExtension) *Response {
return &Response{
Value: &Response_VerifyVoteExtension{res},
Value: &v3.Response_VerifyVoteExtension{res},
}
}

func ToResponseFinalizeBlock(res *ResponseFinalizeBlock) *Response {
return &Response{
Value: &Response_FinalizeBlock{res},
Value: &v3.Response_FinalizeBlock{res},
}
}
Loading

0 comments on commit 5a5beff

Please sign in to comment.