2017-07-27 35 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變量,你可以看到別人是如何註冊的。