wrapper

package module
v1.4.0-beta Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 15 Imported by: 0

README

fabric-sdk-go-wrapper

Code example

wrapper := wrapper.New()
    wrapper.InitializeByFile("config.yaml", "Admin", "org1")
    wrapper.CreateChannel(channelID, channelConfig, ordererID)
    wrapper.JoinChannel(channelID,ordererID)
    pkg,_ := wrapper.CreateChaincodePackage(chaincodePath, chaincodeGoPath)
    wrapper.InstallChaincode(chaincodeID, chaincodePath, pkg)

    ccPolicy := cauthdsl.SignedByAnyMember([]string{orgFullPath})
    err := wrapper.InstantiateChaincode(channelID, chaincodeID, chaincodeGoPath,"0", ccPolicy)
    if err != nil {
        fmt.Println(err)
    }

    payload, err := wrapper.Invoke(channelID, "User1", chaincodeID, "jefke", []string{
        "hello",
        "5",
    })
    //
    fmt.Println(string(payload))
    payload, err = wrapper.Query(channelID, "User1", chaincodeID, "query", []string{"hello"})
    fmt.Println(string(payload))
    err = wrapper.EnrollUser("User1", "org1")
    fmt.Println(err)
    user, err := wrapper.GetEnrolledUser("User1", "org1")
    fmt.Println(err)
    fmt.Println(user)
    wrapper.Close()

Documentation

Index

Constants

View Source
const (
	IdentityTypeUser = "client"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FabricSDKWrapper

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

FabricSDKWrapper implementation

func New

func New() *FabricSDKWrapper

New creates a new FabricSDKWrapper service

func (*FabricSDKWrapper) AsyncInvoke

func (w *FabricSDKWrapper) AsyncInvoke(channelID string, userName string, chaincodeID string, ccFunctionName string, args []string) (channel.Response, error)

AsyncInvoke executes a Hyperledger Fabric transaction asycn

func (*FabricSDKWrapper) Close

func (w *FabricSDKWrapper) Close()

Close closes the SDK

func (*FabricSDKWrapper) CreateChaincodePackage

func (w *FabricSDKWrapper) CreateChaincodePackage(chaincodePath string, chaincodeGoPath string) (*resource.CCPackage, error)

CreateChaincodePackage creates a Hyperledger Fabric package ready for installation

func (*FabricSDKWrapper) CreateChannel

func (w *FabricSDKWrapper) CreateChannel(channelID string, channelConfig string, ordererID string) error

CreateChannel creates a Hyperledger Fabric channel

func (*FabricSDKWrapper) EnrollUser

func (w *FabricSDKWrapper) EnrollUser(userName string, orgName string) error

EnrollUser enrolls a new Fabric CA user

func (*FabricSDKWrapper) GetEnrolledUser

func (w *FabricSDKWrapper) GetEnrolledUser(userName string, orgName string) (*msp.IdentityResponse, error)

GetEnrolledUser returns an enrolled CA user for an organization

func (*FabricSDKWrapper) GetPayloadFromResponse

func (w *FabricSDKWrapper) GetPayloadFromResponse(response *channel.Response) []byte

GetPayloadFromResponse returns the payload from the provided channel response

func (*FabricSDKWrapper) GetSigningIdentity

func (w *FabricSDKWrapper) GetSigningIdentity(orgName string, userName string) (mspapi.SigningIdentity, error)

GetSigningIdentity returns an organization identity

func (*FabricSDKWrapper) InitializeByFile

func (w *FabricSDKWrapper) InitializeByFile(configFile string, orgAdmin string, orgName string) error

InitializeByFile creates a Hyperledger Fabric SDK instance and loads the SDK config from a file path The SDK is initialized per organization

func (*FabricSDKWrapper) InstallChaincode

func (w *FabricSDKWrapper) InstallChaincode(chaincodeID string, chaincodePath string, ccPkg *resource.CCPackage) error

InstallChaincode installs chaincode on a selected peer or all of them

func (*FabricSDKWrapper) InstantiateChaincode

func (w *FabricSDKWrapper) InstantiateChaincode(channelID string, chaincodeID string, chaincodeGoPath string, version string, ccPolicy *common.SignaturePolicyEnvelope) error

InstantiateChaincode instantiates selected chaincode on a channel

func (*FabricSDKWrapper) Invoke

func (w *FabricSDKWrapper) Invoke(
	channelID string,
	userName string,
	chaincodeID string,
	ccFunctionName string,
	args []string,
	targetEndpoints ...string,
) (channel.Response, error)

Invoke executes a Hyperledger Fabric transaction

func (*FabricSDKWrapper) JoinChannel

func (w *FabricSDKWrapper) JoinChannel(channelID string, ordererID string) error

JoinChannel lets the peers join the channel

func (*FabricSDKWrapper) Query

func (w *FabricSDKWrapper) Query(channelID string, userName string, chaincodeID string, ccFunctionName string, args []string, targetEndpoints ...string) (channel.Response, error)

Query executes a Hyperledger Fabric query

func (*FabricSDKWrapper) RemoveEnrolledUser

func (w *FabricSDKWrapper) RemoveEnrolledUser(userName string, orgName string) (*msp.IdentityResponse, error)

RemoveIdentity removes a Hyperledger Fabric CA user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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