ブロックチェーンチュートリアルFabric 1.0ソースgRPC(Fabricに登録されているgRPC Service)2
11594 ワード
兄弟連ブロックチュートリアルFabric 1.0ソースコード分析gRPC(Fabricに登録されているgRPC Service)2.
1.3、Endorser Service(裏書サービス)
1.3.1、Endorser Serviceクライアント
1.3.2、Endorser Serviceサービス
1.4、ChaincodeSupport Service(チェーンコードサポートサービス)
1.4.1、ChaincodeSupport Serviceクライアント
1.4.2、ChaincodeSupport Serviceサービス
1.5、Gossip Service(Gossipサービス)
1.5.1、Gossip Serviceクライアント
1.5.2、Gossip Servicedサービス
2、Ordererノードに登録されているgRPCサービス
2.1、AtomicBroadcast Service(ブロードキャストサービス)
2.1.1、AtomicBroadcast Serviceクライアント
2.1.2、AtomicBroadcast Serviceサービス
1.3、Endorser Service(裏書サービス)
1.3.1、Endorser Serviceクライアント
type EndorserClient interface {
ProcessProposal(ctx context.Context, in *SignedProposal, opts ...grpc.CallOption) (*ProposalResponse, error)
}
type endorserClient struct {
cc *grpc.ClientConn
}
func NewEndorserClient(cc *grpc.ClientConn) EndorserClient {
return &endorserClient{cc}
}
func (c *endorserClient) ProcessProposal(ctx context.Context, in *SignedProposal, opts ...grpc.CallOption) (*ProposalResponse, error) {
out := new(ProposalResponse)
err := grpc.Invoke(ctx, "/protos.Endorser/ProcessProposal", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// protos/peer/peer.pb.go
1.3.2、Endorser Serviceサービス
type EndorserServer interface {
ProcessProposal(context.Context, *SignedProposal) (*ProposalResponse, error)
}
func RegisterEndorserServer(s *grpc.Server, srv EndorserServer) {
s.RegisterService(&_Endorser_serviceDesc, srv)
}
func _Endorser_ProcessProposal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SignedProposal)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(EndorserServer).ProcessProposal(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/protos.Endorser/ProcessProposal",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(EndorserServer).ProcessProposal(ctx, req.(*SignedProposal))
}
return interceptor(ctx, in, info, handler)
}
var _Endorser_serviceDesc = grpc.ServiceDesc{
ServiceName: "protos.Endorser",
HandlerType: (*EndorserServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ProcessProposal",
Handler: _Endorser_ProcessProposal_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "peer/peer.proto",
}
// protos/peer/peer.pb.go
1.4、ChaincodeSupport Service(チェーンコードサポートサービス)
1.4.1、ChaincodeSupport Serviceクライアント
type ChaincodeSupportClient interface {
Register(ctx context.Context, opts ...grpc.CallOption) (ChaincodeSupport_RegisterClient, error)
}
type chaincodeSupportClient struct {
cc *grpc.ClientConn
}
func NewChaincodeSupportClient(cc *grpc.ClientConn) ChaincodeSupportClient {
return &chaincodeSupportClient{cc}
}
func (c *chaincodeSupportClient) Register(ctx context.Context, opts ...grpc.CallOption) (ChaincodeSupport_RegisterClient, error) {
stream, err := grpc.NewClientStream(ctx, &_ChaincodeSupport_serviceDesc.Streams[0], c.cc, "/protos.ChaincodeSupport/Register", opts...)
if err != nil {
return nil, err
}
x := &chaincodeSupportRegisterClient{stream}
return x, nil
}
// protos/peer/peer.pb.go
1.4.2、ChaincodeSupport Serviceサービス
type ChaincodeSupportServer interface {
Register(ChaincodeSupport_RegisterServer) error
}
func RegisterChaincodeSupportServer(s *grpc.Server, srv ChaincodeSupportServer) {
s.RegisterService(&_ChaincodeSupport_serviceDesc, srv)
}
func _ChaincodeSupport_Register_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ChaincodeSupportServer).Register(&chaincodeSupportRegisterServer{stream})
}
var _ChaincodeSupport_serviceDesc = grpc.ServiceDesc{
ServiceName: "protos.ChaincodeSupport",
HandlerType: (*ChaincodeSupportServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "Register",
Handler: _ChaincodeSupport_Register_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "peer/chaincode_shim.proto",
}
// protos/peer/peer.pb.go
1.5、Gossip Service(Gossipサービス)
1.5.1、Gossip Serviceクライアント
type GossipClient interface {
// GossipStream is the gRPC stream used for sending and receiving messages
GossipStream(ctx context.Context, opts ...grpc.CallOption) (Gossip_GossipStreamClient, error)
// Ping is used to probe a remote peer's aliveness
Ping(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
}
type gossipClient struct {
cc *grpc.ClientConn
}
func NewGossipClient(cc *grpc.ClientConn) GossipClient {
return &gossipClient{cc}
}
func (c *gossipClient) GossipStream(ctx context.Context, opts ...grpc.CallOption) (Gossip_GossipStreamClient, error) {
stream, err := grpc.NewClientStream(ctx, &_Gossip_serviceDesc.Streams[0], c.cc, "/gossip.Gossip/GossipStream", opts...)
if err != nil {
return nil, err
}
x := &gossipGossipStreamClient{stream}
return x, nil
}
type Gossip_GossipStreamClient interface {
Send(*Envelope) error
Recv() (*Envelope, error)
grpc.ClientStream
}
type gossipGossipStreamClient struct {
grpc.ClientStream
}
func (x *gossipGossipStreamClient) Send(m *Envelope) error {
return x.ClientStream.SendMsg(m)
}
func (x *gossipGossipStreamClient) Recv() (*Envelope, error) {
m := new(Envelope)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *gossipClient) Ping(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty)
err := grpc.Invoke(ctx, "/gossip.Gossip/Ping", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// protos/gossip/message.pb.go
1.5.2、Gossip Servicedサービス
type GossipServer interface {
// GossipStream is the gRPC stream used for sending and receiving messages
GossipStream(Gossip_GossipStreamServer) error
// Ping is used to probe a remote peer's aliveness
Ping(context.Context, *Empty) (*Empty, error)
}
func RegisterGossipServer(s *grpc.Server, srv GossipServer) {
s.RegisterService(&_Gossip_serviceDesc, srv)
}
func _Gossip_GossipStream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(GossipServer).GossipStream(&gossipGossipStreamServer{stream})
}
type Gossip_GossipStreamServer interface {
Send(*Envelope) error
Recv() (*Envelope, error)
grpc.ServerStream
}
type gossipGossipStreamServer struct {
grpc.ServerStream
}
func (x *gossipGossipStreamServer) Send(m *Envelope) error {
return x.ServerStream.SendMsg(m)
}
func (x *gossipGossipStreamServer) Recv() (*Envelope, error) {
m := new(Envelope)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _Gossip_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(GossipServer).Ping(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gossip.Gossip/Ping",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(GossipServer).Ping(ctx, req.(*Empty))
}
return interceptor(ctx, in, info, handler)
}
var _Gossip_serviceDesc = grpc.ServiceDesc{
ServiceName: "gossip.Gossip",
HandlerType: (*GossipServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Ping",
Handler: _Gossip_Ping_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "GossipStream",
Handler: _Gossip_GossipStream_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "gossip/message.proto",
}
// protos/gossip/message.pb.go
2、Ordererノードに登録されているgRPCサービス
2.1、AtomicBroadcast Service(ブロードキャストサービス)
2.1.1、AtomicBroadcast Serviceクライアント
type AtomicBroadcastClient interface {
// broadcast receives a reply of Acknowledgement for each common.Envelope in order, indicating success or type of failure
Broadcast(ctx context.Context, opts ...grpc.CallOption) (AtomicBroadcast_BroadcastClient, error)
// deliver first requires an Envelope of type DELIVER_SEEK_INFO with Payload data as a mashaled SeekInfo message, then a stream of block replies is received.
Deliver(ctx context.Context, opts ...grpc.CallOption) (AtomicBroadcast_DeliverClient, error)
}
type atomicBroadcastClient struct {
cc *grpc.ClientConn
}
func NewAtomicBroadcastClient(cc *grpc.ClientConn) AtomicBroadcastClient {
return &atomicBroadcastClient{cc}
}
func (c *atomicBroadcastClient) Broadcast(ctx context.Context, opts ...grpc.CallOption) (AtomicBroadcast_BroadcastClient, error) {
stream, err := grpc.NewClientStream(ctx, &_AtomicBroadcast_serviceDesc.Streams[0], c.cc, "/orderer.AtomicBroadcast/Broadcast", opts...)
if err != nil {
return nil, err
}
x := &atomicBroadcastBroadcastClient{stream}
return x, nil
}
func (c *atomicBroadcastClient) Deliver(ctx context.Context, opts ...grpc.CallOption) (AtomicBroadcast_DeliverClient, error) {
stream, err := grpc.NewClientStream(ctx, &_AtomicBroadcast_serviceDesc.Streams[1], c.cc, "/orderer.AtomicBroadcast/Deliver", opts...)
if err != nil {
return nil, err
}
x := &atomicBroadcastDeliverClient{stream}
return x, nil
}
// protos/orderer/ab.pb.go
2.1.2、AtomicBroadcast Serviceサービス
type AtomicBroadcastServer interface {
// broadcast receives a reply of Acknowledgement for each common.Envelope in order, indicating success or type of failure
Broadcast(AtomicBroadcast_BroadcastServer) error
// deliver first requires an Envelope of type DELIVER_SEEK_INFO with Payload data as a mashaled SeekInfo message, then a stream of block replies is received.
Deliver(AtomicBroadcast_DeliverServer) error
}
func RegisterAtomicBroadcastServer(s *grpc.Server, srv AtomicBroadcastServer) {
s.RegisterService(&_AtomicBroadcast_serviceDesc, srv)
}
func _AtomicBroadcast_Broadcast_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(AtomicBroadcastServer).Broadcast(&atomicBroadcastBroadcastServer{stream})
}
func _AtomicBroadcast_Deliver_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(AtomicBroadcastServer).Deliver(&atomicBroadcastDeliverServer{stream})
}
var _AtomicBroadcast_serviceDesc = grpc.ServiceDesc{
ServiceName: "orderer.AtomicBroadcast",
HandlerType: (*AtomicBroadcastServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "Broadcast",
Handler: _AtomicBroadcast_Broadcast_Handler,
ServerStreams: true,
ClientStreams: true,
},
{
StreamName: "Deliver",
Handler: _AtomicBroadcast_Deliver_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "orderer/ab.proto",
}
// protos/orderer/ab.pb.go