How can I implement and deploy pluggable ESCC or VSCC policies in Hyperledger Fabric?

I want to add additional validation and confirmation logic to the existing VSCC and ESCC respectively. Is there any documentation on how I can edit and deploy my own VSCC and ESCC for Hyperledger Fabric?

+3


source to share


2 answers


All system code codes, in particular VSCC and ESCC, must implement the interface 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
}

      

Currently, all system codechains are statically compiled into peer-to-peer code and are listed in the importsysccs.go file . Also, they must be included in the file core.yaml

under the chaining section, for example:



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

      

Then, then you instantiate the circuit code and want to provide custom VSCC and ESCC, you need to specify their names in the LSCC. For example, if you are using the peer cli, you can do it like this:

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

      

+5


source


VSCC and ESCC are system integer codes and the interface is exactly like chaining code, so look at chaining code or go to VSCC source code . You can add your own authentication chain code and associate it with your own chain codes.



System chaining code is generated by a peer executable and does not go through the transactional install / instantiation process. It is loaded when the partner starts up, so registration is required in core / scc / importsysccs.go to register it. Take a look at the systemChaincodes variable and you can see how others register.

+2


source







All Articles