Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/optimise oracle #6

Merged
merged 15 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions abci/client/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,11 @@ func (cli *grpcClient) FetchOracleVotes(ctx context.Context, req *types.RequestF
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))
}

func (cli *grpcClient) DoesOracleResultExist(ctx context.Context, req *types.RequestDoesOracleResultExist) (*types.ResponseDoesOracleResultExist, error) {
return cli.client.DoesOracleResultExist(ctx, types.ToRequestDoesOracleResultExist(req).GetDoesOracleResultExist(), grpc.WaitForReady(true))
}

func (cli *grpcClient) DoesSubAccountBelongToVal(ctx context.Context, req *types.RequestDoesSubAccountBelongToVal) (*types.ResponseDoesSubAccountBelongToVal, error) {
return cli.client.DoesSubAccountBelongToVal(ctx, types.ToRequestDoesSubAccountBelongToVal(req).GetDoesSubAccountBelongToVal(), grpc.WaitForReady(true))
}
156 changes: 104 additions & 52 deletions abci/client/mocks/client.go

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

22 changes: 22 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,28 @@ func (cli *socketClient) ValidateOracleVotes(ctx context.Context, req *types.Req
return reqRes.Response.GetValidateOracleVotes(), cli.Error()
}

func (cli *socketClient) DoesOracleResultExist(ctx context.Context, req *types.RequestDoesOracleResultExist) (*types.ResponseDoesOracleResultExist, error) {
reqRes, err := cli.queueRequest(ctx, types.ToRequestDoesOracleResultExist(req))
if err != nil {
return nil, err
}
if err := cli.Flush(ctx); err != nil {
return nil, err
}
return reqRes.Response.GetDoesOracleResultExist(), cli.Error()
}

func (cli *socketClient) DoesSubAccountBelongToVal(ctx context.Context, req *types.RequestDoesSubAccountBelongToVal) (*types.ResponseDoesSubAccountBelongToVal, error) {
reqRes, err := cli.queueRequest(ctx, types.ToRequestDoesSubAccountBelongToVal(req))
if err != nil {
return nil, err
}
if err := cli.Flush(ctx); err != nil {
return nil, err
}
return reqRes.Response.GetDoesSubAccountBelongToVal(), cli.Error()
}

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

Expand Down
10 changes: 10 additions & 0 deletions abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Application interface {
CreateOracleResultTx(context.Context, *RequestCreateOracleResultTx) (*ResponseCreateOracleResultTx, error)
FetchOracleVotes(context.Context, *RequestFetchOracleVotes) (*ResponseFetchOracleVotes, error)
ValidateOracleVotes(context.Context, *RequestValidateOracleVotes) (*ResponseValidateOracleVotes, error)
DoesOracleResultExist(context.Context, *RequestDoesOracleResultExist) (*ResponseDoesOracleResultExist, error)
DoesSubAccountBelongToVal(context.Context, *RequestDoesSubAccountBelongToVal) (*ResponseDoesSubAccountBelongToVal, error)
}

//-------------------------------------------------------
Expand Down Expand Up @@ -136,3 +138,11 @@ func (BaseApplication) FetchOracleVotes(_ context.Context, req *RequestFetchOrac
func (BaseApplication) ValidateOracleVotes(_ context.Context, req *RequestValidateOracleVotes) (*ResponseValidateOracleVotes, error) {
return &ResponseValidateOracleVotes{}, nil
}

func (BaseApplication) DoesOracleResultExist(_ context.Context, req *RequestDoesOracleResultExist) (*ResponseDoesOracleResultExist, error) {
return &ResponseDoesOracleResultExist{}, nil
}

func (BaseApplication) DoesSubAccountBelongToVal(_ context.Context, req *RequestDoesSubAccountBelongToVal) (*ResponseDoesSubAccountBelongToVal, error) {
return &ResponseDoesSubAccountBelongToVal{}, nil
}
12 changes: 12 additions & 0 deletions abci/types/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ func ToRequestValidateOracleVotes(req *RequestValidateOracleVotes) *Request {
}
}

func ToRequestDoesOracleResultExist(req *RequestDoesOracleResultExist) *Request {
return &Request{
Value: &Request_DoesOracleResultExist{req},
}
}

func ToRequestDoesSubAccountBelongToVal(req *RequestDoesSubAccountBelongToVal) *Request {
return &Request{
Value: &Request_DoesSubAccountBelongToVal{req},
}
}

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

func ToResponseException(errStr string) *Response {
Expand Down
Loading
Loading