Skip to content

Latest commit

 

History

History
109 lines (82 loc) · 2.13 KB

chaincode_proto.md

File metadata and controls

109 lines (82 loc) · 2.13 KB

chaincode.proto

定义 chaincode 相关的结构和服务。

比较重要的包括

ChaincodeID

用来标识一个 chaincode,主要包括路径和名称。

message ChaincodeID {
    //deploy transaction will use the path
    string path = 1;

    //all other requests will use the name (really a hashcode) generated by
    //the deploy transaction
    string name = 2;
}

ChaincodeSpec

定义一个 chaincode 需要的元数据信息。

message ChaincodeSpec {

    enum Type {
        UNDEFINED = 0;
        GOLANG = 1;
        NODE = 2;
        CAR = 3;
        JAVA = 4;
    }

    Type type = 1;
    ChaincodeID chaincodeID = 2;
    ChaincodeInput ctorMsg = 3;
    int32 timeout = 4;
    string secureContext = 5;
    ConfidentialityLevel confidentialityLevel = 6;
    bytes metadata = 7;
    repeated string attributes = 8;
}

其中,ChaincodeInput 主要包括函数和参数。

message ChaincodeInput {

    string function = 1;
    repeated string args  = 2;

}

部署和调用 Chaincode 的消息里面都封装了 ChaincodeSpec 结构。

ChaincodeMessage

围绕 Chaincode 操作,节点之间通过消息进行相互通知。

message ChaincodeMessage {

    enum Type {
        UNDEFINED = 0;
        REGISTER = 1;
        REGISTERED = 2;
        INIT = 3;
        READY = 4;
        TRANSACTION = 5;
        COMPLETED = 6;
        ERROR = 7;
        GET_STATE = 8;
        PUT_STATE = 9;
        DEL_STATE = 10;
        INVOKE_CHAINCODE = 11;
        INVOKE_QUERY = 12;
        RESPONSE = 13;
        QUERY = 14;
        QUERY_COMPLETED = 15;
        QUERY_ERROR = 16;
        RANGE_QUERY_STATE = 17;
        RANGE_QUERY_STATE_NEXT = 18;
        RANGE_QUERY_STATE_CLOSE = 19;
        KEEPALIVE = 20;
    }

    Type type = 1;
    google.protobuf.Timestamp timestamp = 2;
    bytes payload = 3;
    string uuid = 4;
    ChaincodeSecurityContext securityContext = 5;

    //event emmited by chaincode. Used only with Init or Invoke.
    // This event is then stored (currently)
    //with Block.NonHashData.TransactionResult
    ChaincodeEvent chaincodeEvent = 6;
}

这些消息包括多种类型。