{"modulePath":"github.com/sachdev18/sachdevr.18","version":"v0.6.1-preview","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package chaincode\n\n## Constants\n\n```go\nconst (\n\t// DefaultChain is the name of the default chain.\n\tDefaultChain ChainName = \"default\"\n\t// DevModeUserRunsChaincode property allows user to run chaincode in development environment\n\tDevModeUserRunsChaincode string = \"dev\"\n)\n```\n\n## Functions\n\n```go\nfunc Execute(ctxt context.Context, chain *ChaincodeSupport, t *pb.Transaction) ([]byte, *pb.ChaincodeEvent, error)\n```\nExecute - execute transaction or a query\n\n```go\nfunc ExecuteTransactions(ctxt context.Context, cname ChainName, xacts []*pb.Transaction) (succeededTXs []*pb.Transaction, stateHash []byte, ccevents []*pb.ChaincodeEvent, txerrs []error, err error)\n```\nExecuteTransactions - will execute transactions on the array one by one will return an array of errors one for each transaction. If the execution succeeded, array element will be nil. returns \\[]byte of state hash or error\n\n```go\nfunc HandleChaincodeStream(chaincodeSupport *ChaincodeSupport, ctxt context.Context, stream ccintf.ChaincodeStream) error\n```\nHandleChaincodeStream Main loop for handling the associated Chaincode stream\n\n```go\nfunc SetupTestConfig()\n```\nSetupTestConfig setup the config during test execution\n\n```go\nfunc SetupTestLogging()\n```\nSetupTestLogging setup the logging during test execution\n\n## Types\n\n```go\ntype ChainName string\n```\nChainName is the name of the chain to which this chaincode support belongs to.\n\n```go\ntype ChaincodeSupport struct {\n\t// contains filtered or unexported fields\n}\n```\nChaincodeSupport responsible for providing interfacing with chaincodes from the Peer.\n\n```go\nfunc GetChain(name ChainName) *ChaincodeSupport\n```\nGetChain returns the chaincode support for a given chain\n\n```go\nfunc NewChaincodeSupport(chainname ChainName, getPeerEndpoint func() (*pb.PeerEndpoint, error), userrunsCC bool, ccstartuptimeout time.Duration, secHelper crypto.Peer) *ChaincodeSupport\n```\nNewChaincodeSupport creates a new ChaincodeSupport instance\n\n```go\nfunc (chaincodeSupport *ChaincodeSupport) Deploy(context context.Context, t *pb.Transaction) (*pb.ChaincodeDeploymentSpec, error)\n```\nDeploy deploys the chaincode if not in development mode where user is running the chaincode.\n\n```go\nfunc (chaincodeSupport *ChaincodeSupport) Execute(ctxt context.Context, chaincode string, msg *pb.ChaincodeMessage, timeout time.Duration, tx *pb.Transaction) (*pb.ChaincodeMessage, error)\n```\nExecute executes a transaction and waits for it to complete until a timeout value.\n\n```go\nfunc (chaincodeSupport *ChaincodeSupport) HandleChaincodeStream(ctxt context.Context, stream ccintf.ChaincodeStream) error\n```\nHandleChaincodeStream implements ccintf.HandleChaincodeStream for all vms to call with appropriate stream\n\n```go\nfunc (chaincodeSupport *ChaincodeSupport) Launch(context context.Context, t *pb.Transaction) (*pb.ChaincodeID, *pb.ChaincodeInput, error)\n```\nLaunch will launch the chaincode if not running (if running return nil) and will wait for handler of the chaincode to get into FSM ready state.\n\n```go\nfunc (chaincodeSupport *ChaincodeSupport) Register(stream pb.ChaincodeSupport_RegisterServer) error\n```\nRegister the bidi stream entry point called by chaincode to register with the Peer.\n\n```go\nfunc (chaincodeSupport *ChaincodeSupport) Stop(context context.Context, cds *pb.ChaincodeDeploymentSpec) error\n```\nStop stops a chaincode if running\n\n```go\ntype Config struct {\n}\n```\nConfig the config wrapper structure\n\n```go\ntype DuplicateChaincodeHandlerError struct {\n\tChaincodeID *pb.ChaincodeID\n}\n```\nDuplicateChaincodeHandlerError returned if attempt to register same chaincodeID while a stream already exists.\n\n```go\nfunc (d *DuplicateChaincodeHandlerError) Error() string\n```\n\n```go\ntype Handler struct {\n\tsync.RWMutex\n\n\tChatStream  ccintf.ChaincodeStream\n\tFSM         *fsm.FSM\n\tChaincodeID *pb.ChaincodeID\n\t// contains filtered or unexported fields\n}\n```\nHandler responsbile for management of Peer's side of chaincode stream\n\n```go\nfunc (handler *Handler) HandleMessage(msg *pb.ChaincodeMessage) error\n```\nHandleMessage implementation of MessageHandler interface.  Peer's handling of Chaincode messages.\n\n```go\ntype MessageHandler interface {\n\tHandleMessage(msg *pb.ChaincodeMessage) error\n\tSendMessage(msg *pb.ChaincodeMessage) error\n}\n```\nMessageHandler interface for handling chaincode messages (common between Peer chaincode support and chaincode)\n\n","path":"github.com/sachdev18/sachdevr.18/core/chaincode","name":"chaincode","synopsis":"","isRedistributable":true}
