ccprovider

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetChaincodeFromFS

func GetChaincodeFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)

GetChaincodeFromFS returns the chaincode and its package from the file system

func GetChaincodePackage

func GetChaincodePackage(ccname string, ccversion string) ([]byte, error)

GetChaincodePackage returns the chaincode package from the file system

func GetInstalledChaincodes

func GetInstalledChaincodes() (*pb.ChaincodeQueryResponse, error)

GetInstalledChaincodes returns a map whose key is the chaincode id and value is the ChaincodeDeploymentSpec struct for that chaincodes that have been installed (but not necessarily instantiated) on the peer by searching the chaincode install path

func PutChaincodeIntoFS

func PutChaincodeIntoFS(depSpec *pb.ChaincodeDeploymentSpec) error

PutChaincodeIntoFS - serializes chaincode to a package on the file system

func RegisterChaincodeProviderFactory

func RegisterChaincodeProviderFactory(ccfact ChaincodeProviderFactory)

RegisterChaincodeProviderFactory is to be called once to set the factory that will be used to obtain instances of ChaincodeProvider

func SetChaincodesPath

func SetChaincodesPath(path string)

SetChaincodesPath sets the chaincode path for this peer

Types

type CCContext

type CCContext struct {
	//ChainID chain id
	ChainID string

	//Name chaincode name
	Name string

	//Version used to construct the chaincode image and register
	Version string

	//TxID is the transaction id for the proposal (if any)
	TxID string

	//Syscc is this a system chaincode
	Syscc bool

	//SignedProposal for this invoke (if any)
	//this is kept here for access control and in case we need to pass something
	//from this to the chaincode
	SignedProposal *pb.SignedProposal

	//Proposal for this invoke (if any)
	//this is kept here just in case we need to pass something
	//from this to the chaincode
	Proposal *pb.Proposal
	// contains filtered or unexported fields
}

CCContext pass this around instead of string of args

func NewCCContext

func NewCCContext(cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal) *CCContext

NewCCContext just construct a new struct with whatever args

func (*CCContext) GetCanonicalName

func (cccid *CCContext) GetCanonicalName() string

GetCanonicalName returns the canonical name associated with the proposal context

type ChaincodeData

type ChaincodeData struct {
	Name    string `protobuf:"bytes,1,opt,name=name"`
	Version string `protobuf:"bytes,2,opt,name=version"`
	DepSpec []byte `protobuf:"bytes,3,opt,name=depSpec,proto3"`
	Escc    string `protobuf:"bytes,4,opt,name=escc"`
	Vscc    string `protobuf:"bytes,5,opt,name=vscc"`
	Policy  []byte `protobuf:"bytes,6,opt,name=policy"`
}

ChaincodeData defines the datastructure for chaincodes to be serialized by proto

func (*ChaincodeData) ProtoMessage

func (*ChaincodeData) ProtoMessage()

ProtoMessage just exists to make proto happy

func (*ChaincodeData) Reset

func (cd *ChaincodeData) Reset()

Reset resets

func (*ChaincodeData) String

func (cd *ChaincodeData) String() string

String convers to string

type ChaincodeProvider

type ChaincodeProvider interface {
	// GetContext returns a ledger context
	GetContext(ledger ledger.PeerLedger) (context.Context, error)
	// GetCCContext returns an opaque chaincode context
	GetCCContext(cid, name, version, txid string, syscc bool, signedProp *pb.SignedProposal, prop *pb.Proposal) interface{}
	// GetCCValidationInfoFromLCCC returns the VSCC and the policy listed by LCCC for the supplied chaincode
	GetCCValidationInfoFromLCCC(ctxt context.Context, txid string, signedProp *pb.SignedProposal, prop *pb.Proposal, chainID string, chaincodeID string) (string, []byte, error)
	// ExecuteChaincode executes the chaincode given context and args
	ExecuteChaincode(ctxt context.Context, cccid interface{}, args [][]byte) (*pb.Response, *pb.ChaincodeEvent, error)
	// Execute executes the chaincode given context and spec (invocation or deploy)
	Execute(ctxt context.Context, cccid interface{}, spec interface{}) (*pb.Response, *pb.ChaincodeEvent, error)
	// ExecuteWithErrorFilder executes the chaincode given context and spec and returns payload
	ExecuteWithErrorFilter(ctxt context.Context, cccid interface{}, spec interface{}) ([]byte, *pb.ChaincodeEvent, error)
	// Stop stops the chaincode given context and deployment spec
	Stop(ctxt context.Context, cccid interface{}, spec *pb.ChaincodeDeploymentSpec) error
	// ReleaseContext releases the context returned previously by GetContext
	ReleaseContext()
}

ChaincodeProvider provides an abstraction layer that is used for different packages to interact with code in the chaincode package without importing it; more methods should be added below if necessary

func GetChaincodeProvider

func GetChaincodeProvider() ChaincodeProvider

GetChaincodeProvider returns instances of ChaincodeProvider; the actual implementation is controlled by the factory that is registered via RegisterChaincodeProviderFactory

type ChaincodeProviderFactory

type ChaincodeProviderFactory interface {
	NewChaincodeProvider() ChaincodeProvider
}

ChaincodeProviderFactory defines a factory interface so that the actual implementation can be injected

Jump to

Keyboard shortcuts

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