fabric-samples/high-throughput/application-go/functions/update.go
Mark S. Lewis 3c67f51e2e
Use Fabric Gateway client API in high-throughput
The high-throughput sample used the deprecated Go SDK. This change
updates the sample to use the currently supported Fabric Gateway client
API and adds some automated testing to ensure the sample works
correctly.

Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
2025-07-25 11:16:07 +01:00

27 lines
677 B
Go

/*
Copyright 2020 IBM All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package functions
import (
"fmt"
"github.com/hyperledger/fabric-gateway/pkg/client"
)
// Update can be used to update or prune the variable
func Update(contract *client.Contract, function, variableName, change, sign string) ([]byte, error) {
result, err := contract.SubmitTransaction(function, variableName, change, sign)
if err != nil {
return result, fmt.Errorf("failed to Submit transaction: %v", err)
}
result, err = contract.EvaluateTransaction("get", variableName)
if err != nil {
return nil, fmt.Errorf("failed to evaluate transaction: %v", err)
}
return result, err
}