Feature get blocks by height. (#4078)
* Support getting block by height. * Fix to compile. * Http method. * Generate fix. * Install protoc-gen-go-grpc. * Added limit to avoid abuse, small fixes. Co-authored-by: Konstantin <k.potapov@softpro.com>pull/4094/head
parent
c055bc1fd8
commit
c698ee4c5d
@ -1,2 +1,5 @@ |
||||
# used versions |
||||
#go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26 |
||||
#go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1 |
||||
SRC_DIR=$(dirname $0) |
||||
protoc -I ${SRC_DIR}/proto/ ${SRC_DIR}/proto/downloader.proto --go_out=plugins=grpc:${SRC_DIR}/proto |
||||
protoc -I ${SRC_DIR}/proto/ ${SRC_DIR}/proto/downloader.proto --go_out=${SRC_DIR}/proto --go-grpc_out=${SRC_DIR}/proto |
||||
|
@ -1,3 +1,4 @@ |
||||
package downloader |
||||
|
||||
//go:generate protoc downloader.proto --go_out=plugins=grpc:.
|
||||
///go:generate protoc downloader.proto --go_out=plugins=grpc:.
|
||||
//go:generate protoc downloader.proto --go_out=. --go-grpc_out=.
|
||||
|
@ -0,0 +1,101 @@ |
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package downloader |
||||
|
||||
import ( |
||||
context "context" |
||||
grpc "google.golang.org/grpc" |
||||
codes "google.golang.org/grpc/codes" |
||||
status "google.golang.org/grpc/status" |
||||
) |
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7 |
||||
|
||||
// DownloaderClient is the client API for Downloader service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type DownloaderClient interface { |
||||
Query(ctx context.Context, in *DownloaderRequest, opts ...grpc.CallOption) (*DownloaderResponse, error) |
||||
} |
||||
|
||||
type downloaderClient struct { |
||||
cc grpc.ClientConnInterface |
||||
} |
||||
|
||||
func NewDownloaderClient(cc grpc.ClientConnInterface) DownloaderClient { |
||||
return &downloaderClient{cc} |
||||
} |
||||
|
||||
func (c *downloaderClient) Query(ctx context.Context, in *DownloaderRequest, opts ...grpc.CallOption) (*DownloaderResponse, error) { |
||||
out := new(DownloaderResponse) |
||||
err := c.cc.Invoke(ctx, "/downloader.Downloader/Query", in, out, opts...) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return out, nil |
||||
} |
||||
|
||||
// DownloaderServer is the server API for Downloader service.
|
||||
// All implementations must embed UnimplementedDownloaderServer
|
||||
// for forward compatibility
|
||||
type DownloaderServer interface { |
||||
Query(context.Context, *DownloaderRequest) (*DownloaderResponse, error) |
||||
mustEmbedUnimplementedDownloaderServer() |
||||
} |
||||
|
||||
// UnimplementedDownloaderServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedDownloaderServer struct { |
||||
} |
||||
|
||||
func (UnimplementedDownloaderServer) Query(context.Context, *DownloaderRequest) (*DownloaderResponse, error) { |
||||
return nil, status.Errorf(codes.Unimplemented, "method Query not implemented") |
||||
} |
||||
func (UnimplementedDownloaderServer) mustEmbedUnimplementedDownloaderServer() {} |
||||
|
||||
// UnsafeDownloaderServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DownloaderServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDownloaderServer interface { |
||||
mustEmbedUnimplementedDownloaderServer() |
||||
} |
||||
|
||||
func RegisterDownloaderServer(s grpc.ServiceRegistrar, srv DownloaderServer) { |
||||
s.RegisterService(&Downloader_ServiceDesc, srv) |
||||
} |
||||
|
||||
func _Downloader_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
in := new(DownloaderRequest) |
||||
if err := dec(in); err != nil { |
||||
return nil, err |
||||
} |
||||
if interceptor == nil { |
||||
return srv.(DownloaderServer).Query(ctx, in) |
||||
} |
||||
info := &grpc.UnaryServerInfo{ |
||||
Server: srv, |
||||
FullMethod: "/downloader.Downloader/Query", |
||||
} |
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
return srv.(DownloaderServer).Query(ctx, req.(*DownloaderRequest)) |
||||
} |
||||
return interceptor(ctx, in, info, handler) |
||||
} |
||||
|
||||
// Downloader_ServiceDesc is the grpc.ServiceDesc for Downloader service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Downloader_ServiceDesc = grpc.ServiceDesc{ |
||||
ServiceName: "downloader.Downloader", |
||||
HandlerType: (*DownloaderServer)(nil), |
||||
Methods: []grpc.MethodDesc{ |
||||
{ |
||||
MethodName: "Query", |
||||
Handler: _Downloader_Query_Handler, |
||||
}, |
||||
}, |
||||
Streams: []grpc.StreamDesc{}, |
||||
Metadata: "downloader.proto", |
||||
} |
Loading…
Reference in new issue