From bee4f77cf4f003e89e7c633c8139d521fc66a745 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Sat, 5 Oct 2024 11:28:15 +0800 Subject: [PATCH 1/3] feat: add new RPC method for block notifications - Add a new RPC method `FoundNewBlockNonStream` to the BlockService - Update input and output types for existing RPC methods to accommodate new functionality - Modify generated gRPC client and server interfaces to include the new method - Adjust mock implementations to support the new RPC method Signed-off-by: Sean Zheng --- entity/domain/block/biz/block.pb.go | 57 +++++++++++-------- entity/domain/block/biz/block.proto | 1 + entity/domain/block/biz/block_grpc.pb.go | 46 +++++++++++++-- entity/domain/block/biz/block_grpc_mock.pb.go | 35 ++++++++++++ 4 files changed, 110 insertions(+), 29 deletions(-) diff --git a/entity/domain/block/biz/block.pb.go b/entity/domain/block/biz/block.pb.go index 276c987..75fe2d8 100644 --- a/entity/domain/block/biz/block.pb.go +++ b/entity/domain/block/biz/block.pb.go @@ -282,7 +282,7 @@ var file_domain_block_biz_block_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, - 0x53, 0x69, 0x7a, 0x65, 0x32, 0xe7, 0x01, 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x32, 0xae, 0x02, 0x0a, 0x0c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x53, 0x63, 0x61, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x17, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x53, 0x63, 0x61, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, @@ -290,22 +290,27 @@ var file_domain_block_biz_block_proto_rawDesc = []byte{ 0x0d, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, - 0x12, 0x32, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x2e, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x0a, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x73, 0x12, 0x18, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x00, 0x30, 0x01, 0x42, 0x81, - 0x01, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x0a, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x68, 0x6f, 0x72, 0x73, - 0x65, 0x79, 0x61, 0x2f, 0x72, 0x79, 0x7a, 0x65, 0x2f, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, - 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x62, 0x69, 0x7a, - 0xa2, 0x02, 0x03, 0x42, 0x58, 0x58, 0xaa, 0x02, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xca, 0x02, - 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xe2, 0x02, 0x11, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x05, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x45, 0x0a, 0x16, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x4e, 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x1b, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x4e, 0x65, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x12, 0x16, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x47, 0x65, 0x74, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x0a, 0x4c, + 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x18, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x22, 0x00, 0x30, 0x01, 0x42, 0x81, 0x01, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x42, 0x0a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6c, + 0x61, 0x63, 0x6b, 0x68, 0x6f, 0x72, 0x73, 0x65, 0x79, 0x61, 0x2f, 0x72, 0x79, 0x7a, 0x65, 0x2f, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2f, 0x62, 0x69, 0x7a, 0xa2, 0x02, 0x03, 0x42, 0x58, 0x58, 0xaa, 0x02, 0x05, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xca, 0x02, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xe2, 0x02, 0x11, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x05, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -331,14 +336,16 @@ var file_domain_block_biz_block_proto_goTypes = []any{ var file_domain_block_biz_block_proto_depIdxs = []int32{ 0, // 0: block.BlockService.ScanBlock:input_type -> block.ScanBlockRequest 4, // 1: block.BlockService.FoundNewBlock:input_type -> block.Block - 2, // 2: block.BlockService.GetBlock:input_type -> block.GetBlockRequest - 3, // 3: block.BlockService.ListBlocks:input_type -> block.ListBlocksRequest - 4, // 4: block.BlockService.ScanBlock:output_type -> block.Block - 4, // 5: block.BlockService.FoundNewBlock:output_type -> block.Block - 4, // 6: block.BlockService.GetBlock:output_type -> block.Block - 4, // 7: block.BlockService.ListBlocks:output_type -> block.Block - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type + 1, // 2: block.BlockService.FoundNewBlockNonStream:input_type -> block.FoundNewBlockRequest + 2, // 3: block.BlockService.GetBlock:input_type -> block.GetBlockRequest + 3, // 4: block.BlockService.ListBlocks:input_type -> block.ListBlocksRequest + 4, // 5: block.BlockService.ScanBlock:output_type -> block.Block + 4, // 6: block.BlockService.FoundNewBlock:output_type -> block.Block + 4, // 7: block.BlockService.FoundNewBlockNonStream:output_type -> block.Block + 4, // 8: block.BlockService.GetBlock:output_type -> block.Block + 4, // 9: block.BlockService.ListBlocks:output_type -> block.Block + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/entity/domain/block/biz/block.proto b/entity/domain/block/biz/block.proto index cce8fa8..abab5a7 100644 --- a/entity/domain/block/biz/block.proto +++ b/entity/domain/block/biz/block.proto @@ -36,6 +36,7 @@ message ListBlocksRequest { service BlockService { rpc ScanBlock(ScanBlockRequest) returns (stream Block) {} rpc FoundNewBlock(stream Block) returns (stream Block) {} + rpc FoundNewBlockNonStream(FoundNewBlockRequest) returns (Block) {} rpc GetBlock(GetBlockRequest) returns (Block) {} rpc ListBlocks(ListBlocksRequest) returns (stream Block) {} diff --git a/entity/domain/block/biz/block_grpc.pb.go b/entity/domain/block/biz/block_grpc.pb.go index 667054f..8640777 100644 --- a/entity/domain/block/biz/block_grpc.pb.go +++ b/entity/domain/block/biz/block_grpc.pb.go @@ -20,10 +20,11 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - BlockService_ScanBlock_FullMethodName = "/block.BlockService/ScanBlock" - BlockService_FoundNewBlock_FullMethodName = "/block.BlockService/FoundNewBlock" - BlockService_GetBlock_FullMethodName = "/block.BlockService/GetBlock" - BlockService_ListBlocks_FullMethodName = "/block.BlockService/ListBlocks" + BlockService_ScanBlock_FullMethodName = "/block.BlockService/ScanBlock" + BlockService_FoundNewBlock_FullMethodName = "/block.BlockService/FoundNewBlock" + BlockService_FoundNewBlockNonStream_FullMethodName = "/block.BlockService/FoundNewBlockNonStream" + BlockService_GetBlock_FullMethodName = "/block.BlockService/GetBlock" + BlockService_ListBlocks_FullMethodName = "/block.BlockService/ListBlocks" ) // BlockServiceClient is the client API for BlockService service. @@ -34,6 +35,7 @@ const ( type BlockServiceClient interface { ScanBlock(ctx context.Context, in *ScanBlockRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model.Block], error) FoundNewBlock(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[model.Block, model.Block], error) + FoundNewBlockNonStream(ctx context.Context, in *FoundNewBlockRequest, opts ...grpc.CallOption) (*model.Block, error) GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*model.Block, error) ListBlocks(ctx context.Context, in *ListBlocksRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model.Block], error) } @@ -78,6 +80,16 @@ func (c *blockServiceClient) FoundNewBlock(ctx context.Context, opts ...grpc.Cal // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type BlockService_FoundNewBlockClient = grpc.BidiStreamingClient[model.Block, model.Block] +func (c *blockServiceClient) FoundNewBlockNonStream(ctx context.Context, in *FoundNewBlockRequest, opts ...grpc.CallOption) (*model.Block, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(model.Block) + err := c.cc.Invoke(ctx, BlockService_FoundNewBlockNonStream_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *blockServiceClient) GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*model.Block, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(model.Block) @@ -115,6 +127,7 @@ type BlockService_ListBlocksClient = grpc.ServerStreamingClient[model.Block] type BlockServiceServer interface { ScanBlock(*ScanBlockRequest, grpc.ServerStreamingServer[model.Block]) error FoundNewBlock(grpc.BidiStreamingServer[model.Block, model.Block]) error + FoundNewBlockNonStream(context.Context, *FoundNewBlockRequest) (*model.Block, error) GetBlock(context.Context, *GetBlockRequest) (*model.Block, error) ListBlocks(*ListBlocksRequest, grpc.ServerStreamingServer[model.Block]) error } @@ -132,6 +145,9 @@ func (UnimplementedBlockServiceServer) ScanBlock(*ScanBlockRequest, grpc.ServerS func (UnimplementedBlockServiceServer) FoundNewBlock(grpc.BidiStreamingServer[model.Block, model.Block]) error { return status.Errorf(codes.Unimplemented, "method FoundNewBlock not implemented") } +func (UnimplementedBlockServiceServer) FoundNewBlockNonStream(context.Context, *FoundNewBlockRequest) (*model.Block, error) { + return nil, status.Errorf(codes.Unimplemented, "method FoundNewBlockNonStream not implemented") +} func (UnimplementedBlockServiceServer) GetBlock(context.Context, *GetBlockRequest) (*model.Block, error) { return nil, status.Errorf(codes.Unimplemented, "method GetBlock not implemented") } @@ -176,6 +192,24 @@ func _BlockService_FoundNewBlock_Handler(srv interface{}, stream grpc.ServerStre // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type BlockService_FoundNewBlockServer = grpc.BidiStreamingServer[model.Block, model.Block] +func _BlockService_FoundNewBlockNonStream_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(FoundNewBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(BlockServiceServer).FoundNewBlockNonStream(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: BlockService_FoundNewBlockNonStream_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(BlockServiceServer).FoundNewBlockNonStream(ctx, req.(*FoundNewBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _BlockService_GetBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetBlockRequest) if err := dec(in); err != nil { @@ -212,6 +246,10 @@ var BlockService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "block.BlockService", HandlerType: (*BlockServiceServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "FoundNewBlockNonStream", + Handler: _BlockService_FoundNewBlockNonStream_Handler, + }, { MethodName: "GetBlock", Handler: _BlockService_GetBlock_Handler, diff --git a/entity/domain/block/biz/block_grpc_mock.pb.go b/entity/domain/block/biz/block_grpc_mock.pb.go index a63200d..68ee434 100644 --- a/entity/domain/block/biz/block_grpc_mock.pb.go +++ b/entity/domain/block/biz/block_grpc_mock.pb.go @@ -811,6 +811,26 @@ func (mr *MockBlockServiceClientMockRecorder) FoundNewBlock(ctx interface{}, opt return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FoundNewBlock", reflect.TypeOf((*MockBlockServiceClient)(nil).FoundNewBlock), varargs...) } +// FoundNewBlockNonStream mocks base method. +func (m *MockBlockServiceClient) FoundNewBlockNonStream(ctx context.Context, in *FoundNewBlockRequest, opts ...grpc.CallOption) (*model.Block, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "FoundNewBlockNonStream", varargs...) + ret0, _ := ret[0].(*model.Block) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FoundNewBlockNonStream indicates an expected call of FoundNewBlockNonStream. +func (mr *MockBlockServiceClientMockRecorder) FoundNewBlockNonStream(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FoundNewBlockNonStream", reflect.TypeOf((*MockBlockServiceClient)(nil).FoundNewBlockNonStream), varargs...) +} + // GetBlock mocks base method. func (m *MockBlockServiceClient) GetBlock(ctx context.Context, in *GetBlockRequest, opts ...grpc.CallOption) (*model.Block, error) { m.ctrl.T.Helper() @@ -908,6 +928,21 @@ func (mr *MockBlockServiceServerMockRecorder) FoundNewBlock(server interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FoundNewBlock", reflect.TypeOf((*MockBlockServiceServer)(nil).FoundNewBlock), server) } +// FoundNewBlockNonStream mocks base method. +func (m *MockBlockServiceServer) FoundNewBlockNonStream(ctx context.Context, in *FoundNewBlockRequest) (*model.Block, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FoundNewBlockNonStream", ctx, in) + ret0, _ := ret[0].(*model.Block) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FoundNewBlockNonStream indicates an expected call of FoundNewBlockNonStream. +func (mr *MockBlockServiceServerMockRecorder) FoundNewBlockNonStream(ctx, in interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FoundNewBlockNonStream", reflect.TypeOf((*MockBlockServiceServer)(nil).FoundNewBlockNonStream), ctx, in) +} + // GetBlock mocks base method. func (m *MockBlockServiceServer) GetBlock(ctx context.Context, in *GetBlockRequest) (*model.Block, error) { m.ctrl.T.Helper() From be8655e1c9dda98288ea3bd8b359c58eb07d6a40 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Sat, 5 Oct 2024 11:29:08 +0800 Subject: [PATCH 2/3] feat: implement non-streaming block transaction handling - Add a new method `ProcessBlockTransactionsNonStream` to the `TransactionService` for handling non-streaming block transactions. - Update the gRPC client and server interfaces to support the new non-streaming method. - Adjust the implementation for `ListTransactions` to reference the correct stream index. - Modify the mock for `ProcessBlockTransactionsNonStream` to facilitate testing. - Make corresponding changes in the protocol buffer definitions to reflect the new method. Signed-off-by: Sean Zheng --- .../domain/transaction/biz/transaction.pb.go | 69 +++-- .../domain/transaction/biz/transaction.proto | 1 + .../transaction/biz/transaction_grpc.pb.go | 51 +++- .../biz/transaction_grpc_mock.pb.go | 276 ++++++++++++++++++ 4 files changed, 361 insertions(+), 36 deletions(-) diff --git a/entity/domain/transaction/biz/transaction.pb.go b/entity/domain/transaction/biz/transaction.pb.go index e030a06..4e63ea7 100644 --- a/entity/domain/transaction/biz/transaction.pb.go +++ b/entity/domain/transaction/biz/transaction.pb.go @@ -163,36 +163,41 @@ var file_domain_transaction_biz_transaction_proto_rawDesc = []byte{ 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, - 0x7a, 0x65, 0x32, 0x9f, 0x02, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, + 0x7a, 0x65, 0x32, 0xf0, 0x02, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x48, 0x0a, 0x18, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x28, - 0x01, 0x30, 0x01, 0x12, 0x55, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x30, 0x01, 0x12, 0x68, 0x0a, 0x19, 0x4c, 0x69, - 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x79, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, + 0x01, 0x30, 0x01, 0x12, 0x4f, 0x0a, 0x21, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x4e, + 0x6f, 0x6e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x0c, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x22, 0x00, 0x30, 0x01, 0x42, 0xab, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x68, 0x6f, - 0x72, 0x73, 0x65, 0x79, 0x61, 0x2f, 0x72, 0x79, 0x7a, 0x65, 0x2f, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x62, 0x69, 0x7a, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, - 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x0b, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x17, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x00, 0x30, 0x01, 0x12, 0x55, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x23, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x30, 0x01, 0x12, 0x68, 0x0a, 0x19, 0x4c, + 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, + 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2d, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x22, 0x00, 0x30, 0x01, 0x42, 0xab, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x68, + 0x6f, 0x72, 0x73, 0x65, 0x79, 0x61, 0x2f, 0x72, 0x79, 0x7a, 0x65, 0x2f, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x62, 0x69, 0x7a, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, + 0x02, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x0b, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x17, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -216,13 +221,15 @@ var file_domain_transaction_biz_transaction_proto_goTypes = []any{ } var file_domain_transaction_biz_transaction_proto_depIdxs = []int32{ 2, // 0: transaction.TransactionService.ProcessBlockTransactions:input_type -> block.Block - 0, // 1: transaction.TransactionService.ListTransactions:input_type -> transaction.ListTransactionRequest - 1, // 2: transaction.TransactionService.ListTransactionsByAccount:input_type -> transaction.ListTransactionsByAccountRequest - 3, // 3: transaction.TransactionService.ProcessBlockTransactions:output_type -> transaction.Transaction - 3, // 4: transaction.TransactionService.ListTransactions:output_type -> transaction.Transaction - 3, // 5: transaction.TransactionService.ListTransactionsByAccount:output_type -> transaction.Transaction - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type + 2, // 1: transaction.TransactionService.ProcessBlockTransactionsNonStream:input_type -> block.Block + 0, // 2: transaction.TransactionService.ListTransactions:input_type -> transaction.ListTransactionRequest + 1, // 3: transaction.TransactionService.ListTransactionsByAccount:input_type -> transaction.ListTransactionsByAccountRequest + 3, // 4: transaction.TransactionService.ProcessBlockTransactions:output_type -> transaction.Transaction + 3, // 5: transaction.TransactionService.ProcessBlockTransactionsNonStream:output_type -> transaction.Transaction + 3, // 6: transaction.TransactionService.ListTransactions:output_type -> transaction.Transaction + 3, // 7: transaction.TransactionService.ListTransactionsByAccount:output_type -> transaction.Transaction + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name diff --git a/entity/domain/transaction/biz/transaction.proto b/entity/domain/transaction/biz/transaction.proto index 00f3b7e..78c729e 100644 --- a/entity/domain/transaction/biz/transaction.proto +++ b/entity/domain/transaction/biz/transaction.proto @@ -20,6 +20,7 @@ message ListTransactionsByAccountRequest { // Service definition for handling transactions. service TransactionService { rpc ProcessBlockTransactions(stream block.Block) returns (stream Transaction) {} + rpc ProcessBlockTransactionsNonStream(block.Block) returns (stream Transaction) {} rpc ListTransactions(ListTransactionRequest) returns (stream Transaction) {} diff --git a/entity/domain/transaction/biz/transaction_grpc.pb.go b/entity/domain/transaction/biz/transaction_grpc.pb.go index 9077d0a..3ee819a 100644 --- a/entity/domain/transaction/biz/transaction_grpc.pb.go +++ b/entity/domain/transaction/biz/transaction_grpc.pb.go @@ -21,9 +21,10 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - TransactionService_ProcessBlockTransactions_FullMethodName = "/transaction.TransactionService/ProcessBlockTransactions" - TransactionService_ListTransactions_FullMethodName = "/transaction.TransactionService/ListTransactions" - TransactionService_ListTransactionsByAccount_FullMethodName = "/transaction.TransactionService/ListTransactionsByAccount" + TransactionService_ProcessBlockTransactions_FullMethodName = "/transaction.TransactionService/ProcessBlockTransactions" + TransactionService_ProcessBlockTransactionsNonStream_FullMethodName = "/transaction.TransactionService/ProcessBlockTransactionsNonStream" + TransactionService_ListTransactions_FullMethodName = "/transaction.TransactionService/ListTransactions" + TransactionService_ListTransactionsByAccount_FullMethodName = "/transaction.TransactionService/ListTransactionsByAccount" ) // TransactionServiceClient is the client API for TransactionService service. @@ -33,6 +34,7 @@ const ( // Service definition for handling transactions. type TransactionServiceClient interface { ProcessBlockTransactions(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[model.Block, model1.Transaction], error) + ProcessBlockTransactionsNonStream(ctx context.Context, in *model.Block, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model1.Transaction], error) ListTransactions(ctx context.Context, in *ListTransactionRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model1.Transaction], error) ListTransactionsByAccount(ctx context.Context, in *ListTransactionsByAccountRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model1.Transaction], error) } @@ -58,9 +60,28 @@ func (c *transactionServiceClient) ProcessBlockTransactions(ctx context.Context, // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type TransactionService_ProcessBlockTransactionsClient = grpc.BidiStreamingClient[model.Block, model1.Transaction] +func (c *transactionServiceClient) ProcessBlockTransactionsNonStream(ctx context.Context, in *model.Block, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model1.Transaction], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &TransactionService_ServiceDesc.Streams[1], TransactionService_ProcessBlockTransactionsNonStream_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[model.Block, model1.Transaction]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TransactionService_ProcessBlockTransactionsNonStreamClient = grpc.ServerStreamingClient[model1.Transaction] + func (c *transactionServiceClient) ListTransactions(ctx context.Context, in *ListTransactionRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model1.Transaction], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &TransactionService_ServiceDesc.Streams[1], TransactionService_ListTransactions_FullMethodName, cOpts...) + stream, err := c.cc.NewStream(ctx, &TransactionService_ServiceDesc.Streams[2], TransactionService_ListTransactions_FullMethodName, cOpts...) if err != nil { return nil, err } @@ -79,7 +100,7 @@ type TransactionService_ListTransactionsClient = grpc.ServerStreamingClient[mode func (c *transactionServiceClient) ListTransactionsByAccount(ctx context.Context, in *ListTransactionsByAccountRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[model1.Transaction], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &TransactionService_ServiceDesc.Streams[2], TransactionService_ListTransactionsByAccount_FullMethodName, cOpts...) + stream, err := c.cc.NewStream(ctx, &TransactionService_ServiceDesc.Streams[3], TransactionService_ListTransactionsByAccount_FullMethodName, cOpts...) if err != nil { return nil, err } @@ -103,6 +124,7 @@ type TransactionService_ListTransactionsByAccountClient = grpc.ServerStreamingCl // Service definition for handling transactions. type TransactionServiceServer interface { ProcessBlockTransactions(grpc.BidiStreamingServer[model.Block, model1.Transaction]) error + ProcessBlockTransactionsNonStream(*model.Block, grpc.ServerStreamingServer[model1.Transaction]) error ListTransactions(*ListTransactionRequest, grpc.ServerStreamingServer[model1.Transaction]) error ListTransactionsByAccount(*ListTransactionsByAccountRequest, grpc.ServerStreamingServer[model1.Transaction]) error } @@ -117,6 +139,9 @@ type UnimplementedTransactionServiceServer struct{} func (UnimplementedTransactionServiceServer) ProcessBlockTransactions(grpc.BidiStreamingServer[model.Block, model1.Transaction]) error { return status.Errorf(codes.Unimplemented, "method ProcessBlockTransactions not implemented") } +func (UnimplementedTransactionServiceServer) ProcessBlockTransactionsNonStream(*model.Block, grpc.ServerStreamingServer[model1.Transaction]) error { + return status.Errorf(codes.Unimplemented, "method ProcessBlockTransactionsNonStream not implemented") +} func (UnimplementedTransactionServiceServer) ListTransactions(*ListTransactionRequest, grpc.ServerStreamingServer[model1.Transaction]) error { return status.Errorf(codes.Unimplemented, "method ListTransactions not implemented") } @@ -150,6 +175,17 @@ func _TransactionService_ProcessBlockTransactions_Handler(srv interface{}, strea // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type TransactionService_ProcessBlockTransactionsServer = grpc.BidiStreamingServer[model.Block, model1.Transaction] +func _TransactionService_ProcessBlockTransactionsNonStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(model.Block) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(TransactionServiceServer).ProcessBlockTransactionsNonStream(m, &grpc.GenericServerStream[model.Block, model1.Transaction]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TransactionService_ProcessBlockTransactionsNonStreamServer = grpc.ServerStreamingServer[model1.Transaction] + func _TransactionService_ListTransactions_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(ListTransactionRequest) if err := stream.RecvMsg(m); err != nil { @@ -186,6 +222,11 @@ var TransactionService_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, ClientStreams: true, }, + { + StreamName: "ProcessBlockTransactionsNonStream", + Handler: _TransactionService_ProcessBlockTransactionsNonStream_Handler, + ServerStreams: true, + }, { StreamName: "ListTransactions", Handler: _TransactionService_ListTransactions_Handler, diff --git a/entity/domain/transaction/biz/transaction_grpc_mock.pb.go b/entity/domain/transaction/biz/transaction_grpc_mock.pb.go index d4137e7..3cf3a95 100644 --- a/entity/domain/transaction/biz/transaction_grpc_mock.pb.go +++ b/entity/domain/transaction/biz/transaction_grpc_mock.pb.go @@ -285,6 +285,248 @@ func (mr *MockTransactionService_ProcessBlockTransactionsServerMockRecorder) Set return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsServer)(nil).SetTrailer), arg0) } +// MockTransactionService_ProcessBlockTransactionsNonStreamClient is a mock of TransactionService_ProcessBlockTransactionsNonStreamClient interface. +type MockTransactionService_ProcessBlockTransactionsNonStreamClient struct { + ctrl *gomock.Controller + recorder *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder +} + +// MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder is the mock recorder for MockTransactionService_ProcessBlockTransactionsNonStreamClient. +type MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder struct { + mock *MockTransactionService_ProcessBlockTransactionsNonStreamClient +} + +// NewMockTransactionService_ProcessBlockTransactionsNonStreamClient creates a new mock instance. +func NewMockTransactionService_ProcessBlockTransactionsNonStreamClient(ctrl *gomock.Controller) *MockTransactionService_ProcessBlockTransactionsNonStreamClient { + mock := &MockTransactionService_ProcessBlockTransactionsNonStreamClient{ctrl: ctrl} + mock.recorder = &MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) EXPECT() *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder { + return m.recorder +} + +// CloseSend mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) CloseSend() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CloseSend") + ret0, _ := ret[0].(error) + return ret0 +} + +// CloseSend indicates an expected call of CloseSend. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) CloseSend() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).CloseSend)) +} + +// Context mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).Context)) +} + +// Header mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) Header() (metadata.MD, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Header") + ret0, _ := ret[0].(metadata.MD) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Header indicates an expected call of Header. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) Header() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).Header)) +} + +// Recv mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) Recv() (*model0.Transaction, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Recv") + ret0, _ := ret[0].(*model0.Transaction) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Recv indicates an expected call of Recv. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) Recv() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).Recv)) +} + +// RecvMsg mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) RecvMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecvMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).RecvMsg), arg0) +} + +// SendMsg mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) SendMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).SendMsg), arg0) +} + +// Trailer mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamClient) Trailer() metadata.MD { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Trailer") + ret0, _ := ret[0].(metadata.MD) + return ret0 +} + +// Trailer indicates an expected call of Trailer. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamClientMockRecorder) Trailer() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamClient)(nil).Trailer)) +} + +// MockTransactionService_ProcessBlockTransactionsNonStreamServer is a mock of TransactionService_ProcessBlockTransactionsNonStreamServer interface. +type MockTransactionService_ProcessBlockTransactionsNonStreamServer struct { + ctrl *gomock.Controller + recorder *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder +} + +// MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder is the mock recorder for MockTransactionService_ProcessBlockTransactionsNonStreamServer. +type MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder struct { + mock *MockTransactionService_ProcessBlockTransactionsNonStreamServer +} + +// NewMockTransactionService_ProcessBlockTransactionsNonStreamServer creates a new mock instance. +func NewMockTransactionService_ProcessBlockTransactionsNonStreamServer(ctrl *gomock.Controller) *MockTransactionService_ProcessBlockTransactionsNonStreamServer { + mock := &MockTransactionService_ProcessBlockTransactionsNonStreamServer{ctrl: ctrl} + mock.recorder = &MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) EXPECT() *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder { + return m.recorder +} + +// Context mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) Context() context.Context { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Context") + ret0, _ := ret[0].(context.Context) + return ret0 +} + +// Context indicates an expected call of Context. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) Context() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).Context)) +} + +// RecvMsg mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) RecvMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RecvMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// RecvMsg indicates an expected call of RecvMsg. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) RecvMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).RecvMsg), arg0) +} + +// Send mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) Send(arg0 *model0.Transaction) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Send indicates an expected call of Send. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).Send), arg0) +} + +// SendHeader mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) SendHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendHeader indicates an expected call of SendHeader. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).SendHeader), arg0) +} + +// SendMsg mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) SendMsg(arg0 interface{}) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendMsg", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendMsg indicates an expected call of SendMsg. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) SendMsg(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).SendMsg), arg0) +} + +// SetHeader mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) SetHeader(arg0 metadata.MD) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetHeader", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetHeader indicates an expected call of SetHeader. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).SetHeader), arg0) +} + +// SetTrailer mocks base method. +func (m *MockTransactionService_ProcessBlockTransactionsNonStreamServer) SetTrailer(arg0 metadata.MD) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTrailer", arg0) +} + +// SetTrailer indicates an expected call of SetTrailer. +func (mr *MockTransactionService_ProcessBlockTransactionsNonStreamServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockTransactionService_ProcessBlockTransactionsNonStreamServer)(nil).SetTrailer), arg0) +} + // MockTransactionService_ListTransactionsClient is a mock of TransactionService_ListTransactionsClient interface. type MockTransactionService_ListTransactionsClient struct { ctrl *gomock.Controller @@ -852,6 +1094,26 @@ func (mr *MockTransactionServiceClientMockRecorder) ProcessBlockTransactions(ctx return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessBlockTransactions", reflect.TypeOf((*MockTransactionServiceClient)(nil).ProcessBlockTransactions), varargs...) } +// ProcessBlockTransactionsNonStream mocks base method. +func (m *MockTransactionServiceClient) ProcessBlockTransactionsNonStream(ctx context.Context, in *model.Block, opts ...grpc.CallOption) (TransactionService_ProcessBlockTransactionsNonStreamClient, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, in} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "ProcessBlockTransactionsNonStream", varargs...) + ret0, _ := ret[0].(TransactionService_ProcessBlockTransactionsNonStreamClient) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ProcessBlockTransactionsNonStream indicates an expected call of ProcessBlockTransactionsNonStream. +func (mr *MockTransactionServiceClientMockRecorder) ProcessBlockTransactionsNonStream(ctx, in interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, in}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessBlockTransactionsNonStream", reflect.TypeOf((*MockTransactionServiceClient)(nil).ProcessBlockTransactionsNonStream), varargs...) +} + // MockTransactionServiceServer is a mock of TransactionServiceServer interface. type MockTransactionServiceServer struct { ctrl *gomock.Controller @@ -916,3 +1178,17 @@ func (mr *MockTransactionServiceServerMockRecorder) ProcessBlockTransactions(ser mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessBlockTransactions", reflect.TypeOf((*MockTransactionServiceServer)(nil).ProcessBlockTransactions), server) } + +// ProcessBlockTransactionsNonStream mocks base method. +func (m *MockTransactionServiceServer) ProcessBlockTransactionsNonStream(blob *model.Block, server TransactionService_ProcessBlockTransactionsNonStreamServer) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ProcessBlockTransactionsNonStream", blob, server) + ret0, _ := ret[0].(error) + return ret0 +} + +// ProcessBlockTransactionsNonStream indicates an expected call of ProcessBlockTransactionsNonStream. +func (mr *MockTransactionServiceServerMockRecorder) ProcessBlockTransactionsNonStream(blob, server interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessBlockTransactionsNonStream", reflect.TypeOf((*MockTransactionServiceServer)(nil).ProcessBlockTransactionsNonStream), blob, server) +} From 617179268b37f52189ce6ff906bc2d77472439d2 Mon Sep 17 00:00:00 2001 From: Sean Zheng Date: Sat, 5 Oct 2024 11:30:08 +0800 Subject: [PATCH 3/3] feat: implement block processing methods with TODOs - Add a new method `FoundNewBlockNonStream` to handle found blocks - Include a TODO note for implementation in the new method - Add a new method `ProcessBlockTransactionsNonStream` to process transactions for blocks - Include a TODO note for implementation in the new method Signed-off-by: Sean Zheng --- app/domain/block/block_service.go | 5 +++++ app/domain/transaction/transaction_service.go | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/app/domain/block/block_service.go b/app/domain/block/block_service.go index efbabb3..db2de5b 100644 --- a/app/domain/block/block_service.go +++ b/app/domain/block/block_service.go @@ -240,3 +240,8 @@ func (i *impl) ListBlocks(req *biz.ListBlocksRequest, stream grpc.ServerStreamin return nil } + +func (i *impl) FoundNewBlockNonStream(c context.Context, req *biz.FoundNewBlockRequest) (*model.Block, error) { + // TODO: 2024/10/5|sean|implement me + panic("implement me") +} diff --git a/app/domain/transaction/transaction_service.go b/app/domain/transaction/transaction_service.go index d48013c..7288304 100644 --- a/app/domain/transaction/transaction_service.go +++ b/app/domain/transaction/transaction_service.go @@ -181,3 +181,11 @@ func (i *txService) ListTransactionsByAccount( return nil } + +func (i *txService) ProcessBlockTransactionsNonStream( + block *model.Block, + stream grpc.ServerStreamingServer[txM.Transaction], +) error { + // TODO: 2024/10/5|sean|implement me + panic("implement me") +}