chaincode

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Mutual TLS auth client key and cert paths in the chaincode container
	TLSClientKeyPath      string = "/etc/hyperledger/fabric/client.key"
	TLSClientCertPath     string = "/etc/hyperledger/fabric/client.crt"
	TLSClientRootCertPath string = "/etc/hyperledger/fabric/peer.crt"
)
View Source
const (
	// TXSimulatorKey is the context key used to provide a ledger.TxSimulator
	// from the endorser to the chaincode.
	TXSimulatorKey key = "txsimulatorkey"

	// HistoryQueryExecutorKey is the context key used to provide a
	// ledger.HistoryQueryExecutor from the endorser to the chaincode.
	HistoryQueryExecutorKey key = "historyqueryexecutorkey"
)
View Source
const DevModeUserRunsChaincode string = "dev"

DevModeUserRunsChaincode enables chaincode execution in a development environment

Variables

This section is empty.

Functions

func IsDevMode

func IsDevMode() bool

IsDevMode returns true if the peer was configured with development-mode enabled.

func NewTxKey added in v1.2.0

func NewTxKey(channelID, txID string) string

func ParseName added in v1.2.0

func ParseName(ccName string) *sysccprovider.ChaincodeInstance

ParseName parses a chaincode name into a ChaincodeInstance. The name should be of the form "chaincode-name:version/channel-name" with optional elements.

Types

type ACLProvider added in v1.2.0

type ACLProvider interface {
	CheckACL(resName string, channelID string, idinfo interface{}) error
}

An ACLProvider performs access control checks when invoking chaincode.

type ActiveTransactions added in v1.2.0

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

func NewActiveTransactions added in v1.2.0

func NewActiveTransactions() *ActiveTransactions

func (*ActiveTransactions) Add added in v1.2.0

func (a *ActiveTransactions) Add(channelID, txID string) bool

func (*ActiveTransactions) Remove added in v1.2.0

func (a *ActiveTransactions) Remove(channelID, txID string)

type CCProviderImpl added in v1.2.0

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

ccProviderImpl is an implementation of the ccprovider.ChaincodeProvider interface

func NewProvider added in v1.2.0

func NewProvider(cs *ChaincodeSupport) *CCProviderImpl

func (*CCProviderImpl) Execute added in v1.2.0

Execute executes the chaincode given context and spec (invocation or deploy)

func (*CCProviderImpl) ExecuteChaincode added in v1.2.0

func (c *CCProviderImpl) ExecuteChaincode(ctxt context.Context, cccid *ccprovider.CCContext, args [][]byte) (*pb.Response, *pb.ChaincodeEvent, error)

ExecuteChaincode executes the chaincode specified in the context with the specified arguments

func (*CCProviderImpl) GetContext added in v1.2.0

func (c *CCProviderImpl) GetContext(ledger ledger.PeerLedger, txid string) (context.Context, ledger.TxSimulator, error)

GetContext returns a context for the supplied ledger, with the appropriate tx simulator

func (*CCProviderImpl) Stop added in v1.2.0

Stop stops the chaincode given context and spec

type CertGenerator added in v1.2.0

type CertGenerator interface {
	// Generate returns a certificate and private key and associates
	// the hash of the certificates with the given chaincode name
	Generate(ccName string) (*accesscontrol.CertAndPrivKeyPair, error)
}

CertGenerator generates client certificates for chaincode.

type ChaincodeDefinitionGetter added in v1.2.0

type ChaincodeDefinitionGetter interface {
	GetChaincodeDefinition(ctxt context.Context, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, chainID string, chaincodeID string) (ccprovider.ChaincodeDefinition, error)
}

ChaincodeDefinitionGetter is responsible for retrieving a chaincode definition from the system. The definition is used by the InstantiationPolicyChecker.

type ChaincodeSupport

type ChaincodeSupport struct {
	Keepalive       time.Duration
	ExecuteTimeout  time.Duration
	UserRunsCC      bool
	Runtime         Runtime
	ACLProvider     ACLProvider
	HandlerRegistry *HandlerRegistry
	Launcher        Launcher
	// contains filtered or unexported fields
}

ChaincodeSupport responsible for providing interfacing with chaincodes from the Peer.

func NewChaincodeSupport

func NewChaincodeSupport(
	config *Config,
	peerAddress string,
	userRunsCC bool,
	caCert []byte,
	certGenerator CertGenerator,
	packageProvider PackageProvider,
	aclProvider ACLProvider,
	processor Processor,
	sccp sysccprovider.SystemChaincodeProvider,
) *ChaincodeSupport

NewChaincodeSupport creates a new ChaincodeSupport instance.

func (*ChaincodeSupport) Execute

Execute invokes chaincode and returns the original response.

func (*ChaincodeSupport) HandleChaincodeStream

func (cs *ChaincodeSupport) HandleChaincodeStream(ctxt context.Context, stream ccintf.ChaincodeStream) error

HandleChaincodeStream implements ccintf.HandleChaincodeStream for all vms to call with appropriate stream

func (*ChaincodeSupport) Invoke added in v1.2.0

Invoke will invoke chaincode and return the message containing the response. The chaincode will be launched if it is not already running.

func (*ChaincodeSupport) Launch

Launch starts executing chaincode if it is not already running. This method blocks until the peer side handler gets into ready state or encounters a fatal error. If the chaincode is already running, it simply returns.

func (*ChaincodeSupport) Register

Register the bidi stream entry point called by chaincode to register with the Peer.

func (*ChaincodeSupport) Stop

func (cs *ChaincodeSupport) Stop(ctx context.