Chaincode事件为空有效负载-Go Hyperledger Fabric v1.4.1

时间:2019-06-17 16:42:07

标签: hyperledger-fabric hyperledger

将HLF从v1.0更新到v1.4.1后,该代码不再起作用。从链码发送事件时,我收到的有效负载为空。

我认为这是因为我只收到过滤的块,而没有收到完整的块,如此处所述:https://hyperledger-fabric.readthedocs.io/en/release-1.4/peer_event_services.html。 但是,我不知道如何更改收到的块。

这是我的代码,如果其中有任何错误。请注意,在我更新HLF网络之前,它运行良好。

Chaincode:

payload := newValidCsrEventPayload{CsrID: csrId, Name: name}
payloadBytes, err := json.Marshal(payload)
if err != nil {
    return shim.Error("Failed to encode event payload")
    }
    if err := stub.SetEvent("new_valid_csr_"+name+"_"+emailCSR,   []byte(payloadBytes)); err != nil {
         return shim.Error("Unable to set CC event: new Cert Event. Aborting transaction ...")
}

客户:

//prepare channel client context using client context
clientChannelContext := sdk.ChannelContext(channelID, fabsdk.WithUser("User1"), fabsdk.WithOrg("Org1"))
// Channel client is used to query and execute transactions (Org1 is default org)
client, err := channel.New(clientChannelContext)
if err != nil {
    log.Fatalf("Failed to create new channel client: %s", err)
}
// Register chaincode event (pass in channel which receives event details when the event is complete)
var eventID = "new_valid_csr_(.)*"
rceCA, notifierCA, err := client.RegisterChaincodeEvent(ccID, eventID)
if err != nil {
    log.Fatalf("Failed to register chaincode event: %s", err)
}

// Wait for the event
var csridCA string
ccEventCA := <-notifierCA
err = json.Unmarshal(ccEventCA.Payload, &payload)
if err != nil {
    log.Fatalf("Failed to decode event payload")
}
// Unregister chaincode event using registration handle
defer client.UnregisterChaincodeEvent(rceCA)

我的问题是我应该收到一个非空的有效载荷,但是我只会得到空的有效载荷。我必须在哪里设置什么参数来更改接收到的块类型?

0 个答案:

没有答案