2017-07-27 187 views

回答

5

所有系统chaincodes,特别是外阴鳞癌和食管癌,应实现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 
} 

目前所有的系统chaincodes静态编译进同行代码,并在文件中列出。此外,他们必须在chaincode段内core.yaml文件启用,例如:

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 

下一步,然后你实例化你chaincode并愿提供定制VSCC和ESCC您需要提供他们的名字喉癌。例如,如果你将使用同级cli,你可以这样做:

peer chaincode instantiate -o localhost:7050 -n myCC -v 1.0 -C mychannel -c '{"Args": ["init"]}' --vscc myVSCC --escc myESCC 
2

VSCC和ESCC是系统链代码,并且界面与链式代码完全相同,因此请查看链式代码文档或转至VSCC source code。您可以添加您自己的验证系统链接代码并将其与您的链接代码关联。

系统链代码是用对等体可执行文件构建的,并且不通过事务性安装/实例化过程。它在对等体启动时加载,因此它需要在core/scc/importsysccs.go中进行一些注册。看看systemChaincodes变量,你可以看到别人是如何注册的。