fabric

package
v0.0.0-...-c742a63 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMSPKeyfile

func GetMSPKeyfile(homeDir string) (string, error)

GetMSPKeyfile finds the first key file in the keystore directory within the specified home directory.

func Init

func Init(conf *config.Config, lgr *zap.Logger) error

Init initializes client config to interact with the Fabric network

func RegisterAndEnrollUser

func RegisterAndEnrollUser(regReq api.RegistrationRequest) (*lib.Identity, error)

RegisterAndEnrollUser registers and enrolls a new user using the provided admin identity. It creates a user directory, initializes CA clients for the admin and the new user, enrolls the admin, registers the new user, and then enrolls the new user.

func SubmitTransaction

func SubmitTransaction(ctx context.Context, channelID, chaincodeID, fn string, args ...string) ([]byte, error)

SubmitTransaction submits a transaction to the Fabric network. It retrieves user information from the context, creates a gateway client using the user's credentials, and submits the transaction to the specified channel and chaincode.

Types

type CAClient

type CAClient struct {
	// contains filtered or unexported fields
}

CAClient wraps the Fabric CA client with additional functionality.

func NewCAClient

func NewCAClient(cfg *config.Config, userHomeDir ...string) (*CAClient, error)

NewCAClient initializes and returns a new Fabric CA client using configuration from the config package

func (*CAClient) Enroll

func (c *CAClient) Enroll(request *api.EnrollmentRequest) (*lib.Identity, error)

Enroll performs the enrollment process for a user or administrator. It takes an api.EnrollmentRequest and returns the resulting lib.Identity or an error.

func (*CAClient) EnrollAdmin

func (c *CAClient) EnrollAdmin() (*lib.Identity, error)

EnrollAdmin enrolls the admin user and returns the admin identity. If an admin identity is already loaded, it is returned directly. Otherwise, it attempts to enroll the admin using credentials from environment variables or provided arguments.

type GWClient

type GWClient struct {
	*client.Gateway
}

GWClient wraps the Fabric Gateway client.

func NewGatewayClient

func NewGatewayClient(ctx context.Context, conf ...config.Config) (*GWClient, error)

NewGatewayClient creates a new Fabric Gateway client. It establishes a gRPC connection to the Fabric peer, creates user identity and signing objects, and returns a GWClient instance for interacting with the Fabric network.

type MSPKeyCert

type MSPKeyCert struct {
	Cert string `json:"msp.crt"`
	Key  string `json:"msp.key"`
}

MSPKeyCert holds the certificate and key for a user's Membership Service Provider (MSP).

func LoadMSPKeyCert

func LoadMSPKeyCert(homeDir string) (*MSPKeyCert, error)

LoadMSPKeyCert loads the key and certificate from the user's directory.

Jump to

Keyboard shortcuts

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