lifecycle

package
v1.0.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2022 License: Apache-2.0, MIT Imports: 6 Imported by: 1

Documentation

Overview

Package lifecycle provides FPC specific chaincode management functionality.

For more information on the FPC management commands and related constraints on chaincode versions and endorsement policies, see https://github.com/hyperledger/fabric-private-chaincode/blob/main/docs/design/fabric-v2+/fpc-management.md

Example:

adminContext := sdk.Context(fabsdk.WithUser(orgAdmin), fabsdk.WithOrg(orgName))

client, err := lifecycle.New(adminContext)
if err != nil {
	log.Fatal(err)
}

attestationParams, err := sgx.CreateAttestationParamsFromEnvironment()
if err != nil {
	log.Fatal(err)
}

initReq := lifecycle.LifecycleInitEnclaveRequest{
	ChaincodeID:         "my-fpc-chaincode",
	EnclavePeerEndpoint: "mypeer.myorg.example.com", // define the peer where we wanna init our enclave
	AttestationParams:   attestationParams,
}

initTxId, err := client.LifecycleInitEnclave("mychannel", initReq)
if err != nil {
	log.Fatal(err)
}

See also https://github.com/hyperledger/fabric-private-chaincode/blob/main/integration/client_sdk/go/utils.go for a running example.

Index

Constants

View Source
const (
	ERCC               = "ercc"
	InitEnclaveCMD     = "__initEnclave"
	RegisterEnclaveCMD = "registerEnclave"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelClient

type ChannelClient interface {
	Query(chaincodeID string, fcn string, args [][]byte, targetEndpoints ...string) ([]byte, error)
	Execute(chaincodeID string, fcn string, args [][]byte) (string, error)
}

ChannelClient models an interface to query and execute chaincodes

type Client

type Client struct {
	GetChannelClient GetChannelClientFunction
	Converter        CredentialConverter
}

Client enables managing resources in Fabric network. It extends lifecycle.Client (https://pkg.go.dev/github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt#Client) from the standard Fabric Client SDK with additional FPC-specific functionality.

func New

func New(getChannelClient GetChannelClientFunction) (*Client, error)

New returns a FPC resource management client instance.

func (*Client) LifecycleInitEnclave

func (rc *Client) LifecycleInitEnclave(channelID string, req LifecycleInitEnclaveRequest) (string, error)

LifecycleInitEnclave initializes and registers an enclave for a particular FPC chaincode.

type CredentialConverter

type CredentialConverter interface {
	ConvertCredentials(credentialsOnlyAttestation string) (credentialsWithEvidence string, err error)
}

type GetChannelClientFunction

type GetChannelClientFunction func(channelID string) (ChannelClient, error)

type LifecycleInitEnclaveRequest

type LifecycleInitEnclaveRequest struct {
	ChaincodeID         string
	EnclavePeerEndpoint string
	AttestationParams   *sgx.AttestationParams
}

LifecycleInitEnclaveRequest contains init enclave request parameters. In particular, it contains the FPC chaincode ID, the endpoint of the target peer to spawn the enclave, and attestation params to perform attestation and enclave registration.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL