api

package
v0.4.2-ea09166bf79320b... Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrEmptyConfig         = Error(`empty core configuration`)
	ErrInvalidPEMStructure = Error(`invalid PEM structure`)
)
View Source
const (
	ErrPeerAlreadySet = Error(`peer already set`)
	ErrNoPeersForMSP  = Error(`no peers for presented MSP`)
	//ErrNoReadyPeersForMSP = Error(`no ready peers for presented MSP`)
	ErrMSPNotFound  = Error(`MSP not found`)
	ErrPeerNotReady = Error(`peer not ready`)
)
View Source
const (
	CCTypeGoLang = `golang`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockSubscription

type BlockSubscription interface {
	Blocks() <-chan *common.Block
	// DEPRECATED: will migrate to just once Err() <- chan error
	Errors() chan error
	Close() error
}

type CCFetcher

type CCFetcher interface {
	Fetch(ctx context.Context, id *peer.ChaincodeID) (*peer.ChaincodeDeploymentSpec, error)
}

type CSCC

type CSCC interface {
	// JoinChain allows to join channel using presented genesis block
	JoinChain(ctx context.Context, channelName string, genesisBlock *common.Block) error
	// GetConfigBlock returns genesis block of channel
	GetConfigBlock(ctx context.Context, channelName string) (*common.Block, error)
	// GetConfigTree returns configuration tree of channel
	GetConfigTree(ctx context.Context, channelName string) (*peer.ConfigTree, error)
	// Channels returns list of joined channels
	Channels(ctx context.Context) (*peer.ChannelQueryResponse, error)
}

CSCC describes Configuration System Chaincode (CSCC)

type Chaincode

type Chaincode interface {
	// Invoke returns invoke builder for presented chaincode function
	Invoke(fn string) ChaincodeInvokeBuilder
	// Query returns query builder for presented function and arguments
	Query(fn string, args ...string) ChaincodeQueryBuilder
	// Install fetches chaincode from repository and installs it on local peer
	Install(version string)
	// Subscribe returns subscription on chaincode events
	Subscribe(ctx context.Context) (EventCCSubscription, error)
}

Chaincode describes common operations with chaincode

type ChaincodeInvokeBuilder

type ChaincodeInvokeBuilder interface {
	// WithIdentity allows to invoke chaincode from custom identity
	WithIdentity(identity msp.SigningIdentity) ChaincodeInvokeBuilder
	// Transient allows to pass arguments to transient map
	Transient(args TransArgs) ChaincodeInvokeBuilder
	// Async lets get result of invoke without waiting of block commit
	Async(chan<- ChaincodeInvokeResponse) ChaincodeInvokeBuilder
	// ArgBytes set slice of bytes as argument
	ArgBytes([][]byte) ChaincodeInvokeBuilder
	// ArgJSON set slice of JSON-marshalled data
	ArgJSON(in ...interface{}) ChaincodeInvokeBuilder
	// ArgString set slice of strings as arguments
	ArgString(args ...string) ChaincodeInvokeBuilder
	// Do makes invoke with built arguments
	Do(ctx context.Context) (*peer.Response, ChaincodeTx, error)
}

ChaincodeInvokeBuilder describes possibilities how to get invoke results

type ChaincodeInvokeResponse

type ChaincodeInvokeResponse struct {
	TxID    ChaincodeTx
	Payload []byte
	Err     error
}

type ChaincodePackage

type ChaincodePackage interface {
	// Allows to get latest version of chaincode
	Latest(ctx context.Context) (*peer.ChaincodeDeploymentSpec, error)
	// Installs chaincode using defined chaincode fetcher
	Install(ctx context.Context, path, version string) error
	// Instantiate chaincode on channel with presented params
	Instantiate(ctx context.Context, channelName, path, version, policy string, args [][]byte, transArgs TransArgs) error
}

type ChaincodeQueryBuilder

type ChaincodeQueryBuilder interface {
	// WithIdentity allows to invoke chaincode from custom identity
	WithIdentity(identity msp.SigningIdentity) ChaincodeQueryBuilder
	// Transient allows to pass arguments to transient map
	Transient(args TransArgs) ChaincodeQueryBuilder
	// AsBytes allows to get result of querying chaincode as byte slice
	AsBytes(ctx context.Context) ([]byte, error)
	// AsJSON allows to get result of querying chaincode to presented structures using JSON-unmarshalling
	AsJSON(ctx context.Context, out interface{}) error
	// AsProposalResponse allows to get raw peer response
	AsProposalResponse(ctx context.Context) (*peer.ProposalResponse, error)
}

ChaincodeQueryBuilder describe possibilities how to get query results

type ChaincodeTx

type ChaincodeTx string

type Channel

type Channel interface {
	// Chaincode returns chaincode instance by chaincode name
	Chaincode(name string) Chaincode
	// Joins channel
	Join(ctx context.Context) error
}

type Core

type Core interface {
	// Channel returns channel instance by channel name
	Channel(name string) Channel
	// CurrentIdentity identity returns current signing identity used by core
	CurrentIdentity() msp.SigningIdentity
	// CryptoSuite returns current crypto suite implementation
	CryptoSuite() CryptoSuite
	// System allows access to system chaincodes
	System() SystemCC
	// Current peer pool
	PeerPool() PeerPool
	// Chaincode installation
	Chaincode(name string) ChaincodePackage
}

type CryptoSuite

type CryptoSuite interface {
	// Sign is used for signing message by presented private key
	Sign(msg []byte, key interface{}) ([]byte, error)
	// Verify is used for verifying signature for presented message and public key
	Verify(publicKey interface{}, msg, sig []byte) error
	// Hash is used for hashing presented data
	Hash(data []byte) []byte
	// NewPrivateKey generates new private key
	NewPrivateKey() (interface{}, error)
	// GetSignatureAlgorithm
	GetSignatureAlgorithm() x509.SignatureAlgorithm
	// Initialize is used for suite instantiation using presented options
	Initialize(opts config.CryptoSuiteOpts) (CryptoSuite, error)
}

CryptoSuite describes common cryptographic operations

type DeliverClient

type DeliverClient interface {
	// SubscribeCC allows to subscribe on chaincode events using name of channel, chaincode and block offset
	SubscribeCC(ctx context.Context, channelName string, ccName string, seekOpt ...EventCCSeekOption) (EventCCSubscription, error)
	// SubscribeTx allows to subscribe on transaction events by id
	SubscribeTx(ctx context.Context, channelName string, tx ChaincodeTx, seekOpt ...EventCCSeekOption) (TxSubscription, error)
	// SubscribeBlock allows to subscribe on block events. Always returns new instance of block subscription
	SubscribeBlock(ctx context.Context, channelName string, seekOpt ...EventCCSeekOption) (BlockSubscription, error)
}

type DiscoveryChaincode

type DiscoveryChaincode struct {
	Name        string `json:"chaincode_name" yaml:"name"`
	Type        string `json:"type"`
	Version     string `json:"version"`
	Description string `json:"description"`
	Policy      string `json:"policy"`
}

func (DiscoveryChaincode) GetFabricType

func (c DiscoveryChaincode) GetFabricType() peer.ChaincodeSpec_Type

type DiscoveryChannel

type DiscoveryChannel struct {
	Name        string                    `json:"channel_name" yaml:"name"`
	Description string                    `json:"channel_description" yaml:"description"`
	Chaincodes  []DiscoveryChaincode      `json:"chaincodes" yaml:"description"`
	Orderers    []config.ConnectionConfig `json:"orderers" yaml:"orderers"`
}

type DiscoveryProvider

type DiscoveryProvider interface {
	Initialize(opts config.DiscoveryConfigOpts, pool PeerPool) (DiscoveryProvider, error)
	Channels() ([]DiscoveryChannel, error)
	Channel(channelName string) (*DiscoveryChannel, error)
	Chaincode(channelName string, ccName string) (*DiscoveryChaincode, error)
	Chaincodes(channelName string) ([]DiscoveryChaincode, error)
}

type DiscoveryProviderOpts

type DiscoveryProviderOpts map[string]interface{}

type EnvelopeParsingError

type EnvelopeParsingError struct {
	Err error
}

func (EnvelopeParsingError) Error

func (e EnvelopeParsingError) Error() string

type ErrNoReadyPeers

type ErrNoReadyPeers struct {
	MspId string
}

func (ErrNoReadyPeers) Error

func (e ErrNoReadyPeers) Error() string

type ErrUnexpectedHTTPStatus

type ErrUnexpectedHTTPStatus struct {
	Status int
	Body   []byte
}

func (ErrUnexpectedHTTPStatus) Error

func (err ErrUnexpectedHTTPStatus) Error() string

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type EventCCSeekOption

type EventCCSeekOption func() (*orderer.SeekPosition, *orderer.SeekPosition)

func SeekNewest

func SeekNewest() EventCCSeekOption

SeekNewest sets offset to new channel blocks

func SeekOldest

func SeekOldest() EventCCSeekOption

SeekOldest sets offset to channel blocks from beginning

func SeekRange

func SeekRange(start, end uint64) EventCCSeekOption

SeekRange sets offset from one block to another by their numbers

func SeekSingle

func SeekSingle(num uint64) EventCCSeekOption

SeekSingle sets offset from block number

type EventCCSubscription

type EventCCSubscription interface {
	// Events initiates internal GRPC stream and returns channel on chaincode events
	Events() chan *peer.ChaincodeEvent
	// Errors returns errors associated with this subscription
	Errors() chan error
	// Close cancels current subscription
	Close() error
}

type GRPCStreamError

type GRPCStreamError struct {
	Code codes.Code
	Err  error
}

GRPCStreamError contains original error from GRPC stream

func (GRPCStreamError) Error

func (e GRPCStreamError) Error() string

type Identity

type Identity interface {
	// GetSigningIdentity returns signing identity which will use presented crypto suite
	GetSigningIdentity(cs CryptoSuite) msp.SigningIdentity
}

type InvalidTxError

type InvalidTxError struct {
	TxId ChaincodeTx
	Code peer.TxValidationCode
}

func (InvalidTxError) Error

func (e InvalidTxError) Error() string

type Invoker

type Invoker interface {
	// Invoke method allows to invoke chaincode
	Invoke(ctx context.Context, from msp.SigningIdentity, channel string, chaincode string, fn string, args [][]byte, transArgs TransArgs) (*peer.Response, ChaincodeTx, error)
	// Query method allows to query chaincode without sending response to orderer
	Query(ctx context.Context, from msp.SigningIdentity, channel string, chaincode string, fn string, args [][]byte, transArgs TransArgs) (*peer.Response, error)
	// Subscribe allows to subscribe on chaincode events
	Subscribe(ctx context.Context, from msp.SigningIdentity, channel, chaincode string) (EventCCSubscription, error)
}

Invoker interface describes common operations for chaincode

type LSCC

type LSCC interface {
	// GetChaincodeData returns information about instantiated chaincode on target channel
	GetChaincodeData(ctx context.Context, channelName string, ccName string) (*ccprovider.ChaincodeData, error)
	// GetInstalledChaincodes returns list of installed chaincodes on peer
	GetInstalledChaincodes(ctx context.Context) (*peer.ChaincodeQueryResponse, error)
	// GetChaincodes returns list of instantiated chaincodes on channel
	GetChaincodes(ctx context.Context, channelName string) (*peer.ChaincodeQueryResponse, error)
	// GetDeploymentSpec returns spec for installed chaincode
	GetDeploymentSpec(ctx context.Context, channelName string, ccName string) (*peer.ChaincodeDeploymentSpec, error)
	// Install allows to install chaincode using deployment specification
	Install(ctx context.Context, spec *peer.ChaincodeDeploymentSpec) error
	// Deploys allows to instantiate or upgrade chaincode if instantiated
	// Currently, deploy method is not canonical as lscc implementation, but currently we need to get full proposal and it's response to broadcast to orderer
	Deploy(ctx context.Context, channelName string, spec *peer.ChaincodeDeploymentSpec, policy *common.SignaturePolicyEnvelope, opts ...LSCCDeployOption) (*peer.SignedProposal, *peer.ProposalResponse, error)
}

LSCC describes Life Cycle System Chaincode (LSCC)

type LSCCDeployOption

type LSCCDeployOption func(opts *LSCCDeployOptions) error

func WithCollectionConfig

func WithCollectionConfig(config *common.CollectionConfigPackage) LSCCDeployOption

func WithESCC

func WithESCC(escc string) LSCCDeployOption

func WithTransientMap

func WithTransientMap(args TransArgs) LSCCDeployOption

func WithVSCC

func WithVSCC(vscc string) LSCCDeployOption

type LSCCDeployOptions

type LSCCDeployOptions struct {
	Escc             string
	Vscc             string
	CollectionConfig *common.CollectionConfigPackage
	TransArgs        TransArgs
}

type MultiError

type MultiError struct {
	Errors []error
}

func (*MultiError) Add

func (e *MultiError) Add(err error)

func (*MultiError) Error

func (e *MultiError) Error() string

type Orderer

type Orderer interface {
	// Broadcast sends envelope to orderer and returns it's result
	Broadcast(ctx context.Context, envelope *common.Envelope) (*orderer.BroadcastResponse, error)
	// Deliver fetches block from orderer by envelope
	Deliver(ctx context.Context, envelope *common.Envelope) (*common.Block, error)
}

type Peer

type Peer interface {
	// Endorse sends proposal to endorsing peer and returns it's result
	Endorse(ctx context.Context, proposal *peer.SignedProposal, opts ...PeerEndorseOpt) (*peer.ProposalResponse, error)
	// Uri returns url used for grpc connection
	Uri() string
	// Conn returns instance of grpc connection
	Conn() *grpc.ClientConn
	// Close terminates peer connection
	Close() error
}

Peer is common interface for endorsing peer

type PeerEndorseError

type PeerEndorseError struct {
	Status  int32
	Message string
}

PeerEndorseError describes peer endorse error TODO currently not working cause peer embeds error in string

func (PeerEndorseError) Error

func (e PeerEndorseError) Error() string

type PeerEndorseOpt

type PeerEndorseOpt func(opts *PeerEndorseOpts) error

func WithContext

func WithContext(ctx context.Context) PeerEndorseOpt

type PeerEndorseOpts

type PeerEndorseOpts struct {
	Context context.Context
}

type PeerPool

type PeerPool interface {
	Add(mspId string, peer Peer, strategy PeerPoolCheckStrategy) error
	Process(ctx context.Context, mspId string, proposal *peer.SignedProposal) (*peer.ProposalResponse, error)
	DeliverClient(mspId string, identity msp.SigningIdentity) (DeliverClient, error)
	Close() error
}

type PeerPoolCheckStrategy

type PeerPoolCheckStrategy func(ctx context.Context, peer Peer, alive chan bool)

func StrategyGRPC

func StrategyGRPC(d time.Duration) PeerPoolCheckStrategy

type PeerProcessor

type PeerProcessor interface {
	// CreateProposal creates signed proposal for presented cc, function and args using signing identity
	CreateProposal(cc *DiscoveryChaincode, identity msp.SigningIdentity, fn string, args [][]byte, transArgs TransArgs) (*peer.SignedProposal, ChaincodeTx, error)
	// Send sends signed proposal to endorsing peers and collects their responses
	Send(ctx context.Context, proposal *peer.SignedProposal, cc *DiscoveryChaincode, pool PeerPool) ([]*peer.ProposalResponse, error)
}

PeerProcessor is interface for processing transaction

type QSCC

type QSCC interface {
	// GetChainInfo allows to get common info about channel blockchain
	GetChainInfo(ctx context.Context, channelName string) (*common.BlockchainInfo, error)
	// GetBlockByNumber allows to get block by number
	GetBlockByNumber(ctx context.Context, channelName string, blockNumber int64) (*common.Block, error)
	// GetBlockByHash allows to get block by hash
	GetBlockByHash(ctx context.Context, channelName string, blockHash []byte) (*common.Block, error)
	// GetTransactionByID allows to get transaction by id
	GetTransactionByID(ctx context.Context, channelName string, tx ChaincodeTx) (*peer.ProcessedTransaction, error)
	// GetBlockByTxID allows to get block by transaction
	GetBlockByTxID(ctx context.Context, channelName string, tx ChaincodeTx) (*common.Block, error)
}

QSCC describes Query System Chaincode (QSCC)

type SystemCC

type SystemCC interface {
	CSCC() CSCC
	QSCC() QSCC
	LSCC() LSCC
}

SystemCC describes interface to access Fabric System Chaincodes

type TransArgs

type TransArgs map[string][]byte

type TxEvent

type TxEvent struct {
	TxId    ChaincodeTx
	Success bool
	Error   error
}

type TxSubscription

type TxSubscription interface {
	// returns result of current tx: success flag, original peer validation code and error if occurred
	Result() (peer.TxValidationCode, error)
	Close() error
}

EventCCSubscription describes tx subscription

type UnknownEventTypeError

type UnknownEventTypeError struct {
	Type string
}

func (UnknownEventTypeError) Error

func (e UnknownEventTypeError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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