如何在Hyperledger Fabric中实现和部署可插入的ESCC或VSCC策略?

Vin*_*ati 3 hyperledger-fabric

我想在现有的VSCC和ESCC中分别添加一些额外的验证和认可逻辑.有没有关于如何编辑和部署我的自定义VSCC和ESCC到Hyperledger Fabric的文档?

Art*_*ger 6

所有系统链代码,特别是VSCC和ESCC,都应该实现Chaincode接口:

// Chaincode interface must be implemented by all chaincodes. The fabric runs
// the transactions by calling these functions as specified.
type Chaincode interface {
    // Init is called during Instantiate transaction after the chaincode container
    // has been established for the first time, allowing the chaincode to
    // initialize its internal data
    Init(stub ChaincodeStubInterface) pb.Response

    // Invoke is called to update or query the ledger in a proposal transaction.
    // Updated state variables are not committed to the ledger until the
    // transaction is committed.
    Invoke(stub ChaincodeStubInterface) pb.Response
}
Run Code Online (Sandbox Code Playgroud)

目前,所有系统链代码都静态编译成对等代码,并在importsysccs.go文件中列出.此外,它们必须core.yaml在chaincode部分的文件中启用,例如:

chaincode:

    # system chaincodes whitelist. To add system chaincode "myscc" to the
    # whitelist, add "myscc: enable" to the list below, and register in
    # chaincode/importsysccs.go
    system:
        cscc: enable
        lscc: enable
        escc: enable
        vscc: enable
        qscc: enable
Run Code Online (Sandbox Code Playgroud)

接下来,然后您实例化您的链代码,并希望提供自定义VSCC和ESCC,您需要将它们的名称提供给LSCC.例如,如果您将使用peer cli,则可以执行以下操作:

peer chaincode instantiate -o localhost:7050 -n myCC -v 1.0 -C mychannel -c '{"Args": ["init"]}' --vscc myVSCC --escc myESCC
Run Code Online (Sandbox Code Playgroud)