sdk

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AutoDetectSelectionProvider indicates that a selection provider is to be automatically determined using channel capabilities
	AutoDetectSelectionProvider = "auto"
)

Variables

This section is empty.

Functions

func ChaincodeInvoke

func ChaincodeInvoke(chaincodeID string, argsArray []Args) (
	result string, err error)

ChaincodeInvoke invoke chaincode

func ChaincodeInvokeByString

func ChaincodeInvokeByString(chaincodeID, argsStr string) string

ChaincodeInvokeByString call chaincode invoke of hyperledger fabric

func ChaincodeQuery

func ChaincodeQuery(chaincodeID string, argsArray []Args) (result string, err error)

ChaincodeQuery call chaincode query of hyperledger fabric

func ChaincodeQueryByString

func ChaincodeQueryByString(chaincodeID, argsStr string) string

ChaincodeQueryByString call chaincode query of hyperledger fabric

func RegisterBlock

func RegisterBlock(block *BlockRegister) string

RegisterBlock register block of source chain into hyperledger fabric

func RegisterTokenByString

func RegisterTokenByString(chain, tokenAddress string) string

RegisterTokenByString query token info from chain

func RegisterWalletByString

func RegisterWalletByString(key, chain, token string) string

RegisterWalletByString create a new account

Types

type Action

type Action struct {
	Writer io.Writer

	ChannelID   string
	ChaincodeID string
	Args        []Args
	// contains filtered or unexported fields
}

Action is the base implementation of the Action interface.

func (*Action) AdminChannelClient

func (action *Action) AdminChannelClient() (*channel.Client, error)

AdminChannelClient creates a new channel client for performing administrative functions

func (*Action) ChannelClient

func (action *Action) ChannelClient(...channel.ClientOption) (*channel.Client, error)

ChannelClient creates a new channel client

func (*Action) ChannelMgmtClientForUser

func (action *Action) ChannelMgmtClientForUser(channelID string, user mspapi.SigningIdentity) (*channel.Client, error)

ChannelMgmtClientForUser returns the Fabric client for the given user

func (*Action) ChannelProvider

func (action *Action) ChannelProvider() (context.ChannelProvider, error)

ChannelProvider returns the ChannelProvider

func (*Action) Client

func (action *Action) Client(channelID string) (*channel.Client, error)

Client returns the Fabric client for the current user

func (*Action) ClientForUser

func (action *Action) ClientForUser(channelID string, user mspapi.SigningIdentity) (*channel.Client, error)

ClientForUser returns the Channel client for the given user

func (*Action) CreateDiscoveryService

func (action *Action) CreateDiscoveryService(channelID string) (fab.DiscoveryService, error)

CreateDiscoveryService returns a new DiscoveryService for the given channel. This is an implementation of the DiscoveryProvider interface

func (*Action) EndpointConfig

func (action *Action) EndpointConfig() fab.EndpointConfig

EndpointConfig returns the endpoint configuration

func (*Action) EventClient

func (action *Action) EventClient(opts ...event.ClientOption) (*event.Client, error)

EventClient returns the event hub.

func (*Action) GetOrgID

func (action *Action) GetOrgID(mspID string) (string, error)

GetOrgID returns the organization ID for the given MSP ID

func (*Action) GetPeers

func (action *Action) GetPeers() ([]fab.Peer, error)

GetPeers returns the peers in context. This is an implementation of the DiscoveryService interface

func (*Action) Initialize

func (action *Action) Initialize() error

Initialize initializes the action using the config

func (*Action) LedgerClient

func (action *Action) LedgerClient() (*ledger.Client, error)

LedgerClient returns the Fabric client for the current user

func (*Action) LocalContext

func (action *Action) LocalContext() (context.Local, error)

LocalContext creates a new local context

func (*Action) Orderers

func (action *Action) Orderers() ([]fab.Orderer, error)

Orderers returns all Orderers from the set of configured Orderers

func (*Action) OrgAdminChannelClient

func (action *Action) OrgAdminChannelClient(orgID string) (*channel.Client, error)

OrgAdminChannelClient creates a new channel client for the given org in order to perform administrative functions

func (*Action) OrgAdminUser

func (action *Action) OrgAdminUser(orgID string) (mspapi.SigningIdentity, error)

OrgAdminUser returns the pre-enrolled administrative user for the given organization

func (*Action) OrgID

func (action *Action) OrgID() string

OrgID returns the organization ID of the first peer in the list of peers

func (*Action) OrgOfPeer

func (action *Action) OrgOfPeer(peerURL string) (string, error)

OrgOfPeer returns the organization ID of the given peer

func (*Action) OrgUser

func (action *Action) OrgUser(orgID, username string) (mspapi.SigningIdentity, error)

OrgUser returns an already enrolled user for the given organization

func (*Action) Peer

func (action *Action) Peer() fab.Peer

Peer returns the first peer in the list of selected peers

func (*Action) PeerConfig

func (action *Action) PeerConfig() (*fab.PeerConfig, error)

PeerConfig returns the PeerConfig for the first peer in the current org

func (*Action) PeerFromURL

func (action *Action) PeerFromURL(url string) (fab.Peer, bool)

PeerFromURL returns the peer for the given URL

func (*Action) Peers

func (action *Action) Peers() []fab.Peer

Peers returns the peers

func (*Action) PeersByOrg

func (action *Action) PeersByOrg() map[string][]fab.Peer

PeersByOrg returns the peers mapped by organization

func (*Action) RandomOrderer

func (action *Action) RandomOrderer() (fab.Orderer, error)

RandomOrderer chooses a random Orderer from the set of configured Orderers

func (*Action) ResourceMgmtClient

func (action *Action) ResourceMgmtClient() (*resmgmt.Client, error)

ResourceMgmtClient returns a resource management client for the current user

func (*Action) ResourceMgmtClientForOrg

func (action *Action) ResourceMgmtClientForOrg(orgID string) (*resmgmt.Client, error)

ResourceMgmtClientForOrg returns a resource management client for the given org

func (*Action) ResourceMgmtClientForUser

func (action *Action) ResourceMgmtClientForUser(user mspapi.SigningIdentity) (*resmgmt.Client, error)

ResourceMgmtClientForUser returns the Fabric client for the given user

func (*Action) Set

func (action *Action) Set(channelID, chaincodeID string, argsArray []Args)

Set args for chaincode invoke

func (*Action) Terminate

func (action *Action) Terminate()

Terminate closes any open connections. This function should be called at the end of every command invocation.

func (*Action) User

func (action *Action) User() (mspapi.SigningIdentity, error)

User returns the enrolled user. If the user doesn't exist then a new user is enrolled.

type Args

type Args struct {
	Func string   `json:"Func"`
	Args []string `json:"Args"`
}

Args is used for marshalling arguments to chaincode invocations

func ArgsArray

func ArgsArray(argsStr string) ([]Args, error)

ArgsArray returns an array of args used in chaincode invocations

func ParseArgs

func ParseArgs(argsStr string) (*Args, error)

ParseArgs returns an args used in chaincode invocations

type BlockRegister

type BlockRegister struct {
	Height string        `json:"height,omitempty"`
	Txs    []*TxRegister `json:"transactions,omitempty"`
}

BlockRegister registered block

type CallResult

type CallResult struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Result  interface{} `json:"result"`
}

CallResult api call result

type FabConfig

type FabConfig struct {
	ConfigFile         string
	UserName           string
	ChainID            string
	ChannelID          string
	SelectionProvider  string
	OrdererURL         string
	IsLoggingEnabledFo bool                // enable log
	ConfigProvider     core.ConfigProvider // provider returns the config provider
	Concurrency        uint16
	OrgIDs             []string
	PeerURL            string
	PeerURLs           []string
	MaxAttempts        int
	InitialBackoff     time.Duration
	MaxBackoff         time.Duration
	BackoffFactor      float64
	Verbose            bool
	Iterations         int
	PrintPayloadOnly   bool
	PrintFormat        string
	Writer             string
	Base64             bool
}

FabConfig wrap configuration values

func Config

func Config() *FabConfig

Config get config's singleton

type QueryTask

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

QueryTask is the query task

func NewQueryTask

func NewQueryTask(id string, channelClient *channel.Client, targets []fab.Peer,
	chaincodeID string, args *Args,
	verbose bool, payloadOnly bool, callback func(err error)) *QueryTask

NewQueryTask creates a new query Task

func (*QueryTask) Invoke

func (t *QueryTask) Invoke()

Invoke invokes the query task

type TxInfo

type TxInfo struct {
	Contract string `json:"contract,omitempty"`
	From     string `json:"from,omitempty"`
	To       string `json:"to,omitempty"`
	Amount   string `json:"amount,omitempty"`
	GasUsed  string `json:"gasUsed,omitempty"`
	GasPrice string `json:"gasPrice,omitempty"`
	TxHash   string `json:"txHash,omitempty"`
	Height   string `json:"height,omitempty"`
	Status   string `json:"status,omitempty"`
}

TxInfo info of Tx

type TxRegister

type TxRegister struct {
	Key       string  `json:"key,omitempty"`
	ChainName string  `json:"chain,omitempty"`
	TokenName string  `json:"token,omitempty"`
	Addr      string  `json:"address,omitempty"`
	Amount    string  `json:"amount,omitempty"`
	GasUsed   string  `json:"gasUsed,omitempty"`
	GasPrice  string  `json:"gasPrice,omitempty"`
	Info      *TxInfo `json:"info,omitempty"`
}

TxRegister registered Tx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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