Invoking the chaincode

To trigger the invoke function, you can call the name of the chaincode application function and pass shim.ChaincodeStubInterface as the signature. In the insurance claim case, we defined several functions to support our use case, for example:

AddCompany, ReportLost, RequestedInfo, SubmitClaim, ConfirmClaimSubmission, ApproveClaim.

We also defined a query to keep track of the current claim request and getHistory to get all of the historical claim transaction records, as follows:

func (c *ClaimContract) Invoke(stub shim.ChaincodeStubInterface) pb.Response {
function, args := stub.GetFunctionAndParameters()
if function == "AddCompany" {
return c.AddCompany(stub, args)
} else if function == "ReportLost" {
return c.ReportLost(stub, args)
} else if function == "RequestedInfo" {
return c.RequestedInfo(stub, args)
} else if function == "SubmitClaim" {
return c.SubmitClaim(stub, args)
} else if function == "ConfirmClaimSubmission" {
return c.ConfirmClaimSubmission(stub, args)
} else if function == "ApproveClaim" {
return c.ApproveClaim(stub, args)
} else if function == "query" {
return c.query(stub, args)
} else if function == "getHistory" {
return c.getHistory(stub, args)
}


return shim.Error("Invalid function name")
}
..................Content has been hidden....................

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