mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
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>
22 lines
501 B
Go
22 lines
501 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"
|
|
)
|
|
|
|
// Query can be used to read the latest value of a variable
|
|
func Query(contract *client.Contract, function, variableName string) ([]byte, error) {
|
|
result, err := contract.EvaluateTransaction(function, variableName)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to evaluate transaction: %v", err)
|
|
}
|
|
return result, err
|
|
}
|