Main function

Last but not least, we will add the main function: the initial point of a Go program. When an instance of the chaincode is deployed on a peer, the main function is executed to start the chaincode.

In line 2 of the following snippet, the chaincode is instantiated. The function shim.Start starts the chaincode in line 4 and registers it with the peer, as follows:

func main() { 
   twc := new(TradeWorkflowChaincode) 
   twc.testMode = false 
   err := shim.Start(twc) 
   if err != nil { 
         fmt.Printf("Error starting Trade Workflow chaincode: %s", err) 
   } 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.170.55