Documentation ¶
Index ¶
- func ChaincodePackageExists(ccname string, ccversion string) (bool, error)
- func EnableCCInfoCache()
- func GetChaincodePackage(ccname string, ccversion string) ([]byte, error)
- func GetInstalledChaincodes() (*pb.ChaincodeQueryResponse, error)
- func PutChaincodeIntoFS(depSpec *pb.ChaincodeDeploymentSpec) error
- func RegisterChaincodeProviderFactory(ccfact ChaincodeProviderFactory)
- func SetChaincodesPath(path string)
- type CCContext
- type CCInfoFSImpl
- type CCInfoProvider
- type CCPackage
- type CDSData
- type CDSPackage
- func (ccpack *CDSPackage) GetChaincodeData() *ChaincodeData
- func (ccpack *CDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec
- func (ccpack *CDSPackage) GetDepSpecBytes() []byte
- func (ccpack *CDSPackage) GetId() []byte
- func (ccpack *CDSPackage) GetPackageObject() proto.Message
- func (ccpack *CDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)
- func (ccpack *CDSPackage) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)
- func (ccpack *CDSPackage) PutChaincodeToFS() error
- func (ccpack *CDSPackage) ValidateCC(ccdata *ChaincodeData) error
- type ChaincodeData
- type ChaincodeProvider
- type ChaincodeProviderFactory
- type SignedCDSData
- type SignedCDSPackage
- func (ccpack *SignedCDSPackage) GetChaincodeData() *ChaincodeData
- func (ccpack *SignedCDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec
- func (ccpack *SignedCDSPackage) GetDepSpecBytes() []byte
- func (ccpack *SignedCDSPackage) GetId() []byte
- func (ccpack *SignedCDSPackage) GetInstantiationPolicy() []byte
- func (ccpack *SignedCDSPackage) GetPackageObject() proto.Message
- func (ccpack *SignedCDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)
- func (ccpack *SignedCDSPackage) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)
- func (ccpack *SignedCDSPackage) PutChaincodeToFS() error
- func (ccpack *SignedCDSPackage) ValidateCC(ccdata *ChaincodeData) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChaincodePackageExists ¶
ChaincodePackageExists returns whether the chaincode package exists in the file system
func EnableCCInfoCache ¶
func EnableCCInfoCache()
EnableCCInfoCache can be called to enable the cache
func GetChaincodePackage ¶
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 puts chaincode information in the file system (and also in the cache to prime it) if the cache is enabled, or directly from the file system otherwise
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 ¶
GetCanonicalName returns the canonical name associated with the proposal context
type CCInfoFSImpl ¶
type CCInfoFSImpl struct{}
CCInfoFSStorageMgr is an implementation of CCInfoProvider backed by the file system
func (*CCInfoFSImpl) GetChaincode ¶
func (*CCInfoFSImpl) GetChaincode(ccname string, ccversion string) (CCPackage, error)
GetChaincodeFromFS this is a wrapper for hiding package implementation.
func (*CCInfoFSImpl) PutChaincode ¶
func (*CCInfoFSImpl) PutChaincode(depSpec *pb.ChaincodeDeploymentSpec) (CCPackage, error)
PutChaincodeIntoFS is a wrapper for putting raw ChaincodeDeploymentSpec using CDSPackage. This is only used in UTs
type CCInfoProvider ¶
type CCInfoProvider interface { // GetChaincode returns information for the chaincode with the // supplied name and version GetChaincode(ccname string, ccversion string) (CCPackage, error) // PutChaincode stores the supplied chaincode info PutChaincode(depSpec *pb.ChaincodeDeploymentSpec) (CCPackage, error) }
CCInfoProvider is responsible to provide backend storage for information about chaincodes. Multiple implementations can persist data to a file system or store them in a cache
func NewCCInfoCache ¶
func NewCCInfoCache(ccfs CCInfoProvider) CCInfoProvider
NewCCInfoCache returns a new cache on top of the supplied CCInfoProvider instance
type CCPackage ¶
type CCPackage interface { //InitFromBuffer initialize the package from bytes InitFromBuffer(buf []byte) (*ChaincodeData, error) // InitFromFS gets the chaincode from the filesystem (includes the raw bytes too) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error) // PutChaincodeToFS writes the chaincode to the filesystem PutChaincodeToFS() error // GetDepSpec gets the ChaincodeDeploymentSpec from the package GetDepSpec() *pb.ChaincodeDeploymentSpec // GetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package GetDepSpecBytes() []byte // ValidateCC validates and returns the chaincode deployment spec corresponding to // ChaincodeData. The validation is based on the metadata from ChaincodeData // One use of this method is to validate the chaincode before launching ValidateCC(ccdata *ChaincodeData) error // GetPackageObject gets the object as a proto.Message GetPackageObject() proto.Message // GetChaincodeData gets the ChaincodeData GetChaincodeData() *ChaincodeData // GetId gets the fingerprint of the chaincode based on package computation GetId() []byte }
CCPackage encapsulates a chaincode package which can be
raw ChaincodeDeploymentSpec SignedChaincodeDeploymentSpec
Attempt to keep the interface at a level with minimal interface for possible generalization.
func GetCCPackage ¶
GetCCPackage tries each known package implementation one by one till the right package is found
type CDSData ¶
type CDSData struct { //CodeHash hash of CodePackage from ChaincodeDeploymentSpec CodeHash []byte `protobuf:"bytes,1,opt,name=codehash,proto3"` //MetaDataHash hash of Name and Version from ChaincodeDeploymentSpec MetaDataHash []byte `protobuf:"bytes,2,opt,name=metadatahash,proto3"` }
CDSData is data stored in the LSCC on instantiation of a CC for CDSPackage. This needs to be serialized for ChaincodeData hence the protobuf format
func (*CDSData) ProtoMessage ¶
func (*CDSData) ProtoMessage()
ProtoMessage just exists to make proto happy
type CDSPackage ¶
type CDSPackage struct {
// contains filtered or unexported fields
}
CDSPackage encapsulates ChaincodeDeploymentSpec.
func (*CDSPackage) GetChaincodeData ¶
func (ccpack *CDSPackage) GetChaincodeData() *ChaincodeData
GetChaincodeData gets the ChaincodeData
func (*CDSPackage) GetDepSpec ¶
func (ccpack *CDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec
GetDepSpec gets the ChaincodeDeploymentSpec from the package
func (*CDSPackage) GetDepSpecBytes ¶
func (ccpack *CDSPackage) GetDepSpecBytes() []byte
GetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package
func (*CDSPackage) GetId ¶
func (ccpack *CDSPackage) GetId() []byte
GetId gets the fingerprint of the chaincode based on package computation
func (*CDSPackage) GetPackageObject ¶
func (ccpack *CDSPackage) GetPackageObject() proto.Message
GetPackageObject gets the ChaincodeDeploymentSpec as proto.Message
func (*CDSPackage) InitFromBuffer ¶
func (ccpack *CDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)
InitFromBuffer sets the buffer if valid and returns ChaincodeData
func (*CDSPackage) InitFromFS ¶
func (ccpack *CDSPackage) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)
InitFromFS returns the chaincode and its package from the file system
func (*CDSPackage) PutChaincodeToFS ¶
func (ccpack *CDSPackage) PutChaincodeToFS() error
PutChaincodeToFS - serializes chaincode to a package on the file system
func (*CDSPackage) ValidateCC ¶
func (ccpack *CDSPackage) ValidateCC(ccdata *ChaincodeData) error
ValidateCC returns error if the chaincode is not found or if its not a ChaincodeDeploymentSpec
type ChaincodeData ¶
type ChaincodeData struct { //Name of the chaincode Name string `protobuf:"bytes,1,opt,name=name"` //Version of the chaincode Version string `protobuf:"bytes,2,opt,name=version"` //Escc for the chaincode instance Escc string `protobuf:"bytes,3,opt,name=escc"` //Vscc for the chaincode instance Vscc string `protobuf:"bytes,4,opt,name=vscc"` //Policy endorsement policy for the chaincode instance Policy []byte `protobuf:"bytes,5,opt,name=policy,proto3"` //Data data specific to the package Data []byte `protobuf:"bytes,6,opt,name=data,proto3"` //Id of the chaincode that's the unique fingerprint for the CC //This is not currently used anywhere but serves as a good //eyecatcher Id []byte `protobuf:"bytes,7,opt,name=id,proto3"` //InstantiationPolicy for the chaincode InstantiationPolicy []byte `protobuf:"bytes,8,opt,name=instantiation_policy,proto3"` }
ChaincodeData defines the datastructure for chaincodes to be serialized by proto Type provides an additional check by directing to use a specific package after instantiation Data is Type specifc (see CDSPackage and SignedCDSPackage)
func (*ChaincodeData) ProtoMessage ¶
func (*ChaincodeData) ProtoMessage()
ProtoMessage just exists to make proto happy
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{} // GetCCValidationInfoFromLSCC returns the VSCC and the policy listed by LSCC for the supplied chaincode GetCCValidationInfoFromLSCC(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
type SignedCDSData ¶
type SignedCDSData struct { CodeHash []byte `protobuf:"bytes,1,opt,name=hash"` MetaDataHash []byte `protobuf:"bytes,2,opt,name=metadatahash"` SignatureHash []byte `protobuf:"bytes,3,opt,name=signaturehash"` }
SignedCDSData is data stored in the LSCC on instantiation of a CC for SignedCDSPackage. This needs to be serialized for ChaincodeData hence the protobuf format
func (*SignedCDSData) Equals ¶
func (data *SignedCDSData) Equals(other *SignedCDSData) bool
Equals data equals other
func (*SignedCDSData) ProtoMessage ¶
func (*SignedCDSData) ProtoMessage()
ProtoMessage just exists to make proto happy
type SignedCDSPackage ¶
type SignedCDSPackage struct {
// contains filtered or unexported fields
}
SignedCDSPackage encapsulates SignedChaincodeDeploymentSpec.
func (*SignedCDSPackage) GetChaincodeData ¶
func (ccpack *SignedCDSPackage) GetChaincodeData() *ChaincodeData
GetChaincodeData gets the ChaincodeData
func (*SignedCDSPackage) GetDepSpec ¶
func (ccpack *SignedCDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec
GetDepSpec gets the ChaincodeDeploymentSpec from the package
func (*SignedCDSPackage) GetDepSpecBytes ¶
func (ccpack *SignedCDSPackage) GetDepSpecBytes() []byte
GetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package
func (*SignedCDSPackage) GetId ¶
func (ccpack *SignedCDSPackage) GetId() []byte
GetId gets the fingerprint of the chaincode based on package computation
func (*SignedCDSPackage) GetInstantiationPolicy ¶
func (ccpack *SignedCDSPackage) GetInstantiationPolicy() []byte
GetInstantiationPolicy gets the instantiation policy from the package
func (*SignedCDSPackage) GetPackageObject ¶
func (ccpack *SignedCDSPackage) GetPackageObject() proto.Message
GetPackageObject gets the ChaincodeDeploymentSpec as proto.Message
func (*SignedCDSPackage) InitFromBuffer ¶
func (ccpack *SignedCDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)
InitFromBuffer sets the buffer if valid and returns ChaincodeData
func (*SignedCDSPackage) InitFromFS ¶
func (ccpack *SignedCDSPackage) InitFromFS(ccname string, ccversion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)
InitFromFS returns the chaincode and its package from the file system
func (*SignedCDSPackage) PutChaincodeToFS ¶
func (ccpack *SignedCDSPackage) PutChaincodeToFS() error
PutChaincodeToFS - serializes chaincode to a package on the file system
func (*SignedCDSPackage) ValidateCC ¶
func (ccpack *SignedCDSPackage) ValidateCC(ccdata *ChaincodeData) error
ValidateCC returns error if the chaincode is not found or if its not a ChaincodeDeploymentSpec