From 11167992451b14b86274dadce9e09f76cc41c9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Macedo?= Date: Tue, 12 Dec 2023 07:13:13 -0300 Subject: [PATCH] Fix CCAPI waiting for inexistant Custom Event response MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Macedo --- ccapi/chaincode/eventHandler.go | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/ccapi/chaincode/eventHandler.go b/ccapi/chaincode/eventHandler.go index ebf8933..9504b7f 100644 --- a/ccapi/chaincode/eventHandler.go +++ b/ccapi/chaincode/eventHandler.go @@ -6,7 +6,6 @@ import ( "fmt" "os" - "github.com/hyperledger/fabric-sdk-go/pkg/client/channel" "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab" ) @@ -81,30 +80,17 @@ func (event EventHandler) Execute(ccEvent *fab.CCEvent) { return } - // Invoke executeEvent tx - var res *channel.Response - var err error + // Invoke tx + txName := "executeEvent" if event.ReadOnly { - res, _, err = Invoke(os.Getenv("CHANNEL"), os.Getenv("CCNAME"), "runEvent", [][]byte{args}, nil) - if err != nil { - fmt.Println("error invoking transaction: ", err) - return - } - } else { - res, _, err = Invoke(os.Getenv("CHANNEL"), os.Getenv("CCNAME"), "executeEvent", [][]byte{args}, nil) - if err != nil { - fmt.Println("error invoking transaction: ", err) - return - } + txName = "runEvent" } - var response map[string]interface{} - nerr := json.Unmarshal(res.Payload, &response) - if nerr != nil { - fmt.Println("error unmarshalling response: ", nerr) + _, _, err := Invoke(os.Getenv("CHANNEL"), os.Getenv("CCNAME"), txName, [][]byte{args}, nil) + if err != nil { + fmt.Println("error invoking transaction: ", err) return } - fmt.Println("Response: ", response) } else { fmt.Println("Event type not supported") }