Skip to content

Commit

Permalink
add validateOracleVotes hook
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-soon authored and yan-soon committed Apr 18, 2024
1 parent 1dcdefd commit 8149b71
Show file tree
Hide file tree
Showing 13 changed files with 1,047 additions and 335 deletions.
4 changes: 4 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,7 @@ func (cli *grpcClient) SignGossipVote(ctx context.Context, req *types.RequestSig
func (cli *grpcClient) PrepareOracleVotes(ctx context.Context, req *types.RequestPrepareOracleVotes) (*types.ResponsePrepareOracleVotes, error) {
return cli.client.PrepareOracleVotes(ctx, types.ToRequestPrepareOracleVotes(req).GetPrepareOracleVotes(), grpc.WaitForReady(true))
}

func (cli *grpcClient) ValidateOracleVotes(ctx context.Context, req *types.RequestValidateOracleVotes) (*types.ResponseValidateOracleVotes, error) {
return cli.client.ValidateOracleVotes(ctx, types.ToRequestValidateOracleVotes(req).GetValidateOracleVotes(), grpc.WaitForReady(true))
}
26 changes: 26 additions & 0 deletions abci/client/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,17 @@ func (cli *socketClient) PrepareOracleVotes(ctx context.Context, req *types.Requ
return reqRes.Response.GetPrepareOracleVotes(), cli.Error()
}

func (cli *socketClient) ValidateOracleVotes(ctx context.Context, req *types.RequestValidateOracleVotes) (*types.ResponseValidateOracleVotes, error) {
reqRes, err := cli.queueRequest(ctx, types.ToRequestValidateOracleVotes(req))
if err != nil {
return nil, err
}
if err := cli.Flush(ctx); err != nil {
return nil, err
}
return reqRes.Response.GetValidateOracleVotes(), cli.Error()
}

func (cli *socketClient) queueRequest(ctx context.Context, req *types.Request) (*ReqRes, error) {
reqres := NewReqRes(req)

Expand Down
5 changes: 5 additions & 0 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Application interface {
// Hooks
SignGossipVote(context.Context, *RequestSignGossipVote) (*ResponseSignGossipVote, error)
PrepareOracleVotes(context.Context, *RequestPrepareOracleVotes) (*ResponsePrepareOracleVotes, error)
ValidateOracleVotes(context.Context, *RequestValidateOracleVotes) (*ResponseValidateOracleVotes, error)
}

//-------------------------------------------------------
Expand Down Expand Up @@ -131,3 +132,7 @@ func (BaseApplication) SignGossipVote(_ context.Context, req *RequestSignGossipV
func (BaseApplication) PrepareOracleVotes(_ context.Context, req *RequestPrepareOracleVotes) (*ResponsePrepareOracleVotes, error) {
return &ResponsePrepareOracleVotes{}, nil
}

func (BaseApplication) ValidateOracleVotes(_ context.Context, req *RequestValidateOracleVotes) (*ResponseValidateOracleVotes, error) {
return &ResponseValidateOracleVotes{}, nil
}
6 changes: 6 additions & 0 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ func ToRequestPrepareOracleVotes(req *RequestPrepareOracleVotes) *Request {
}
}

func ToRequestValidateOracleVotes(req *RequestValidateOracleVotes) *Request {
return &Request{
Value: &Request_ValidateOracleVotes{req},
}
}

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

func ToResponseException(errStr string) *Response {
Expand Down
26 changes: 26 additions & 0 deletions abci/types/mocks/application.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8149b71

Please sign in to comment.