首页 > 其他 > 详细

区块链教程Fabric1.0源代码分析Peer EndorserClient(Endorser

时间:2018-11-06 16:27:56      阅读:216      评论:0      收藏:0      [点我收藏+]
区块链教程Fabric1.0源代码分析Peer EndorserClient(Endorser客户端),2018年下半年,区块链行业正逐渐褪去发展之初的浮躁、回归理性,表面上看相关人才需求与身价似乎正在回落。但事实上,正是初期泡沫的渐退,让人们更多的关注点放在了区块链真正的技术之上。

Fabric 1.0源代码笔记 之 Peer #EndorserClient(Endorser客户端)

1、EndorserClient概述

EndorserClient相关代码分布如下:

  • protos/peer/peer.pb.go,EndorserClient接口及实现。
  • peer/common/common.go,EndorserClient相关工具函数。

2、EndorserClient接口定义

type EndorserClient interface {
????//处理Proposal
????ProcessProposal(ctx context.Context, in *SignedProposal, opts ...grpc.CallOption) (*ProposalResponse, error)
}
//代码在protos/peer/peer.pb.go

3、EndorserClient接口实现

EndorserClient接口实现,即endorserClient结构体及方法。

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...)
????return out, nil
}
//代码在protos/peer/peer.pb.go

4、EndorserClient工具函数

//获取Endorser客户端
func GetEndorserClient() (pb.EndorserClient, error) {
????clientConn, err := peer.NewPeerClientConnection()
????endorserClient := pb.NewEndorserClient(clientConn)
????return endorserClient, nil
}
//代码在peer/common/common.go

感谢关注兄弟连区块链教程分享!

区块链教程Fabric1.0源代码分析Peer EndorserClient(Endorser

原文:http://blog.51cto.com/14041296/2313445

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!