Skip to content

Instantly share code, notes, and snippets.

@vitiko
Created May 20, 2018 19:11
Show Gist options
  • Save vitiko/533f5943e4f3f9154c7a8ac36bc9c66d to your computer and use it in GitHub Desktop.
Save vitiko/533f5943e4f3f9154c7a8ac36bc9c66d to your computer and use it in GitHub Desktop.
Cars chaincode base methods
// Init initializes chain code - sets chaincode "owner"
func (cc *Chaincode) Init(stub shim.ChaincodeStubInterface) peer.Response {
// set owner of chain code with special permissions , based on tx creator certificate
// owner info stored in chaincode state as entry with key "OWNER" and content is serialized "Grant" structure
return owner.SetFromCreator(cc.router.Context(`init`, stub))
}
// Invoke - entry point for chain code invocations
func (cc *Chaincode) Invoke(stub shim.ChaincodeStubInterface) peer.Response {
// delegate handling to router
return cc.router.Handle(stub)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment