编程语言
首页 > 编程语言> > Hyperledger Fabric 链码(2) 接口

Hyperledger Fabric 链码(2) 接口

作者:互联网

1.Chaincode interface:每个链码程序必须实现链码接口,用以响应接收的事务。

1.1 go语言的“shim ”包中,接口规范如下:

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
}

2. ChaincodeStubinterface:shim中的另一个重要接口,用于访问和修改帐本,以及实现链间调用

共定义了36个成员方法
eg.

标签:transaction,Fabric,Invoke,Init,key,链码,Hyperledger,string
来源: https://blog.csdn.net/thefist11cc/article/details/116864969