Finally, we arrive at the most interesting, but most complex, part of the chaincode development: implementing the code of the ReportAccident transaction and the publication of the NewAccident event. Let's start by adding the following empty function to the end of the file:
// reportAccident - Create a new accident report, store into statefunc (t *InsuranceChaincode) reportAccident(stub shim.ChaincodeStubInterface, args []string) pb.Response { var err error // simple data model arguments // 0=longitude 1=latitude 2=occured at 3=involved vehicle // 52.0920511 5.06641270 2018-08-03T10:20:20.325Z base.Vehicle#1012 fmt.Println("- Accident Report created") return shim.Success(nil)}
This function will contain ...