sample_chain/document/peer节点返回消息.md

29 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### peer节点返回背书结果
#### 将接收到的提案响应按照交易 ID 进行归类,并将它们存储到一个映射结构中
1.获取ChainCodeMessage结构体对象Payload字段的内容并进行反序列化得到pb.ProposalResponse对象
2.定义一个将交易ID与提案相应关联的map对象proposalResponse (cmap.ConcurrentMap[string, []*pb.ProposalResponse])
3.定义了一个类型为 []*pb.ProposalResponse的变量prs用于存储提案响应。检查 proposalResponse中是否已经存在了与当前消息的交易 IDmsg.TxID对应的提案响应数组。如果不存在则创建一个空的数组并将其与交易 ID 关联起来
4.从 proposalResponse 中获取与当前消息的交易 ID 关联的提案响应数组 prs将当前接收到的提案响应 pr添加到 prs 数组中。将更新后的 prs数组重新关联到交易 ID 上更新proposalResponse中的值
#### 解析提案请求
1.验证msg.Proposal.Signature字段检查提案的签名是否正确
2.反序列化ChaincodeMessage类型消息(msg)的个各字段,得到签名后的提案(SignedProposal)、提案响应(ProposalResponse)等信息
3.验证签名头(SignatureHeader)信息与客户端身份信息是否一致
4.校验提案响应负载的Hash值、提案响应的状态信息和背书结果以及背书者的签名是否有效
#### 生成交易(事务)并打包
1.将背书者存储至背书者集合([]*pb.Endorsement)中
2.获取交易的字节数组(txBytes)与签名头信息共同实例化Payload结构体
3.反序列化Payload结构体对象得到payloadBytes并使用客户端的私钥进行签名将签名值放入Envelope结构体中的Signature字段