2017-08-02 54 views

回答

3

您可以通過使用Hyperledger Fabric chaincode實現任何業務邏輯,這本質上是一個簡單的程序。 Chaincode通過對應用程序提交的事務進行操作來管理分類帳狀態,並確保跨網絡對等方保持一致。

Hyperledger Fabric目前支持用Go編寫的鏈式代碼,而未來將添加對nodeJS和Java的支持。定義如下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 
} 

所以,你可以實現你的cryptocurrency到chaincode。爲了得到如何實現它的靈感,你可能想看看下面的演示應用balance-transfer


還有一個相當類似的問題最近也被問到mailing list

+0

非常感謝您的回覆。 據我所知,我必須自己檢查所有交易歷史並批准當前交易嗎? –

+0

@Kirill,是的,你必須自己實現業務邏輯。 –

+0

好的,但我怎麼能得到交易的歷史? –