区块链教程Fabric1.0源代码分析Proposal(提案),2018年下半年,区块链行业正逐渐褪去发展之初的浮躁、回归理性,表面上看相关人才需求与身价似乎正在回落。但事实上,正是初期泡沫的渐退,让人们更多的关注点放在了区块链真正的技术之上。

Fabric1.0源代码笔记之Proposal(提案)

1、Proposal概述

Proposal,即向Endorser发起的提案。 Proposal代码分布在protos/utils、protos/peer目录下,目录结构如下:

protos/utils目录:     proputils.go,Proposal工具函数。     txutils.go,Proposal工具函数。 protos/peer目录:     proposal.pb.go,Proposal相关结构体定义。

2、Proposal相关结构体定义

2.1、SignedProposal定义

type SignedProposal struct {
    ProposalBytes []byte //Proposal序列化,即type Proposal struct
    Signature []byte //signer.Sign(ProposalBytes)
}
//代码在protos/peer/proposal.pb.go

2.2、Proposal定义

type Proposal struct {
    Header []byte //Header序列化,即type Header struct
    Payload []byte //ChaincodeProposalPayload序列化,即type ChaincodeProposalPayload struct
    Extension []byte //扩展
}
//代码在protos/peer/proposal.pb.go

2.3、ChaincodeProposalPayload定义

type ChaincodeProposalPayload struct {
    Input []byte //ChaincodeInvocationSpec序列化,即type ChaincodeInvocationSpec struct
    TransientMap map[string][]byte //瞬态映射
}
//代码在protos/peer/proposal.pb.go

3、ProposalResponse结构体定义

3.1、ProposalResponse定义

type ProposalResponse struct {
    Version int32
    Timestamp *google_protobuf1.Timestamp
    Response *Response //type Response struct,peer.Response{Status: 200, Message: "OK"}}
    Payload []byte
    Endorsement *Endorsement //type Endorsement struct
}
//代码在protos/peer/proposal_response.pb.go

3.2、Response定义

type Response struct { //peer.Response{Status: 200, Message: "OK"}}
    Status int32
    Message string
    Payload []byte
}
//代码在protos/peer/proposal_response.pb.go

3.3、Endorsement定义

type Endorsement struct {
    Endorser []byte //bccspmsp.signer
    Signature []byte
}
//代码在protos/peer/proposal_response.pb.go