Skip to content
Permalink
v1.0.5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
package blockchain
import (
"fmt"
"github.com/hyperledger/fabric-sdk-go/api/apitxn/chclient"
"time"
)
// InvokeHello
func (setup *FabricSetup) InvokeHello(value string) (string, error) {
// Prepare arguments
var args []string
args = append(args, "invoke")
args = append(args, "invoke")
args = append(args, "hello")
args = append(args, value)
eventID := "eventInvoke"
// Add data that will be visible in the proposal, like a description of the invoke request
transientDataMap := make(map[string][]byte)
transientDataMap["result"] = []byte("Transient data in hello invoke")
// Register a notification handler on the client
notifier := make(chan *chclient.CCEvent)
rce, err := setup.client.RegisterChaincodeEvent(notifier, setup.ChainCodeID, eventID)
if err != nil {
return "", fmt.Errorf("failed to register chaincode evet: %v", err)
}
// Create a request (proposal) and send it
response, err := setup.client.Execute(chclient.Request{ChaincodeID: setup.ChainCodeID, Fcn: args[0], Args: [][]byte{[]byte(args[1]), []byte(args[2]), []byte(args[3])}, TransientMap: transientDataMap})
if err != nil {
return "", fmt.Errorf("failed to move funds: %v", err)
}
// Wait for the result of the submission
select {
case ccEvent := <-notifier:
fmt.Printf("Received CC event: %s\n", ccEvent)
case <-time.After(time.Second * 20):
return "", fmt.Errorf("did NOT receive CC event for eventId(%s)", eventID)
}
// Unregister the notification handler previously created on the client
err = setup.client.UnregisterChaincodeEvent(rce)
return response.TransactionID.ID, nil
}