1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | type customEvent struct { Type string `json:"type"` Description string `json:"description"` } func CreateLoanApplication(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) { fmt.Println("Entering CreateLoanApplication") if len(args) < 2 { fmt.Println("Invalid number of args") return nil, errors.New("Expected at least two arguments for loan application creation") } var loanApplicationId = args[0] var loanApplicationInput = args[1] err := stub.PutState(loanApplicationId, []byte(loanApplicationInput)) if err != nil { fmt.Println("Could not save loan application to ledger", err) return nil, err } var event = customEvent = {"createLoanApplication", "Successfully created loan application with ID " + loanApplicationId} eventBytes, err ;= json.Marshal(&event) if err != nil { return nil, err } err = stub.SetEvent("evtSender", eventBytes) if err != nil { fmt.Println("Could not set event for loan application creation", err) } fmt.Println("Successfully saved loan application") return nil, nil } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |