區塊鏈教程Fabric1.0源代碼分析Peer EndorserClient(Endorser
阿新 • • 發佈:2018-11-06
正是 筆記 方法 end signed 兄弟連 人才 RoCE int 區塊鏈教程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