fabric: github.com/hyperledger/fabric/core/common/ccprovider Index | Files

package ccprovider

import "github.com/hyperledger/fabric/core/common/ccprovider"

# Copyright State Street Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0

Index

Package Files

cc_statedb_artifacts_provider.go ccinfocache.go ccprovider.go cdspackage.go common.go sigcdspackage.go targzmetadataprovider.go

func ChaincodePackageExists Uses

func ChaincodePackageExists(ccname string, ccversion string) (bool, error)

ChaincodePackageExists returns whether the chaincode package exists in the file system

func ExtractFileEntries Uses

func ExtractFileEntries(tarBytes []byte, databaseType string) (map[string][]*TarFileEntry, error)

ExtractFileEntries extract file entries from the given `tarBytes`. A file entry is included in the returned results only if it is located in a directory under the indicated databaseType directory Example for chaincode indexes: "META-INF/statedb/couchdb/indexes/indexColorSortName.json" Example for collection scoped indexes: "META-INF/statedb/couchdb/collections/collectionMarbles/indexes/indexCollMarbles.json" An empty string will have the effect of returning all statedb metadata. This is useful in validating an archive in the future with multiple database types

func ExtractStatedbArtifactsForChaincode Uses

func ExtractStatedbArtifactsForChaincode(ccNameVersion string) (installed bool, statedbArtifactsTar []byte, err error)

ExtractStatedbArtifactsAsTarbytes extracts the statedb artifacts from the code package tar and create a statedb artifact tar. The state db artifacts are expected to contain state db specific artifacts such as index specification in the case of couchdb. This function is intended to be used during chaincode instantiate/upgrade so that statedb artifacts can be created.

func ExtractStatedbArtifactsFromCCPackage Uses

func ExtractStatedbArtifactsFromCCPackage(ccpackage CCPackage) (statedbArtifactsTar []byte, err error)

ExtractStatedbArtifactsFromCCPackage extracts the statedb artifacts from the code package tar and create a statedb artifact tar. The state db artifacts are expected to contain state db specific artifacts such as index specification in the case of couchdb. This function is called during chaincode instantiate/upgrade (from above), and from install, so that statedb artifacts can be created.

func GetChaincodePackageFromPath Uses

func GetChaincodePackageFromPath(ccNameVersion string, ccInstallPath string) ([]byte, error)

GetChaincodePackage returns the chaincode package from the file system

func GetInstalledChaincodes Uses

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 MetadataAsTarEntries Uses

func MetadataAsTarEntries(code []byte) ([]byte, error)

MetadataAsTarEntries extracts metadata from a chaincode package

func NewCCInfoCache Uses

func NewCCInfoCache(cs CCCacheSupport) *ccInfoCacheImpl

NewCCInfoCache returns a new cache on top of the supplied CCInfoProvider instance

func SetChaincodesPath Uses

func SetChaincodesPath(path string)

SetChaincodesPath sets the chaincode path for this peer

type CCCacheSupport Uses

type CCCacheSupport interface {
    // GetChaincode is needed by the cache to get chaincode data
    GetChaincode(ccNameVersion string) (CCPackage, error)
}

type CCInfoFSImpl Uses

type CCInfoFSImpl struct {
    GetHasher GetHasher
}

CCInfoFSImpl provides the implementation for CC on the FS and the access to it It implements CCCacheSupport

func (*CCInfoFSImpl) GetChaincode Uses

func (cifs *CCInfoFSImpl) GetChaincode(ccNameVersion string) (CCPackage, error)

GetChaincodeFromFS this is a wrapper for hiding package implementation. It calls GetChaincodeFromPath with the chaincodeInstallPath

func (*CCInfoFSImpl) GetChaincodeCodePackage Uses

func (cifs *CCInfoFSImpl) GetChaincodeCodePackage(ccNameVersion string) ([]byte, error)

func (*CCInfoFSImpl) GetChaincodeDepSpec Uses

func (cifs *CCInfoFSImpl) GetChaincodeDepSpec(ccNameVersion string) (*pb.ChaincodeDeploymentSpec, error)

func (*CCInfoFSImpl) GetChaincodeFromPath Uses

func (cifs *CCInfoFSImpl) GetChaincodeFromPath(ccNameVersion string, path string) (CCPackage, error)

GetChaincodeFromPath this is a wrapper for hiding package implementation.

func (*CCInfoFSImpl) GetChaincodeInstallPath Uses

func (*CCInfoFSImpl) GetChaincodeInstallPath() string

GetChaincodeInstallPath returns the path to the installed chaincodes

func (*CCInfoFSImpl) ListInstalledChaincodes Uses

func (cifs *CCInfoFSImpl) ListInstalledChaincodes(dir string, ls DirEnumerator, ccFromPath ChaincodeExtractor) ([]chaincode.InstalledChaincode, error)

ListInstalledChaincodes retrieves the installed chaincodes

func (*CCInfoFSImpl) PutChaincode Uses

func (cifs *CCInfoFSImpl) PutChaincode(depSpec *pb.ChaincodeDeploymentSpec) (CCPackage, error)

PutChaincode is a wrapper for putting raw ChaincodeDeploymentSpec using CDSPackage. This is only used in UTs

type CCPackage Uses

type CCPackage interface {
    //InitFromBuffer initialize the package from bytes
    InitFromBuffer(buf []byte) (*ChaincodeData, 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 Uses

func GetCCPackage(buf []byte, bccsp bccsp.BCCSP) (CCPackage, error)

GetCCPackage tries each known package implementation one by one till the right package is found

func GetChaincodeFromFS Uses

func GetChaincodeFromFS(ccNameVersion string) (CCPackage, error)

GetChaincodeFromFS retrieves chaincode information from the file system

func LoadPackage Uses

func LoadPackage(ccNameVersion string, path string, getHasher GetHasher) (CCPackage, error)

LoadPackage loads a chaincode package from the file system

type CDSData Uses

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) Equals Uses

func (data *CDSData) Equals(other *CDSData) bool

Equals data equals other

func (*CDSData) ProtoMessage Uses

func (*CDSData) ProtoMessage()

ProtoMessage just exists to make proto happy

func (*CDSData) Reset Uses

func (data *CDSData) Reset()

Reset resets

func (*CDSData) String Uses

func (data *CDSData) String() string

String converts to string

type CDSPackage Uses

type CDSPackage struct {
    GetHasher GetHasher
    // contains filtered or unexported fields
}

CDSPackage encapsulates ChaincodeDeploymentSpec.

func (*CDSPackage) GetChaincodeData Uses

func (ccpack *CDSPackage) GetChaincodeData() *ChaincodeData

GetChaincodeData gets the ChaincodeData

func (*CDSPackage) GetDepSpec Uses

func (ccpack *CDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec

GetDepSpec gets the ChaincodeDeploymentSpec from the package

func (*CDSPackage) GetDepSpecBytes Uses

func (ccpack *CDSPackage) GetDepSpecBytes() []byte

GetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package

func (*CDSPackage) GetId Uses

func (ccpack *CDSPackage) GetId() []byte

GetId gets the fingerprint of the chaincode based on package computation

func (*CDSPackage) GetPackageObject Uses

func (ccpack *CDSPackage) GetPackageObject() proto.Message

GetPackageObject gets the ChaincodeDeploymentSpec as proto.Message

func (*CDSPackage) InitFromBuffer Uses

func (ccpack *CDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)

InitFromBuffer sets the buffer if valid and returns ChaincodeData

func (*CDSPackage) InitFromFS Uses

func (ccpack *CDSPackage) InitFromFS(ccNameVersion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)

InitFromFS returns the chaincode and its package from the file system

func (*CDSPackage) InitFromPath Uses

func (ccpack *CDSPackage) InitFromPath(ccNameVersion string, path string) ([]byte, *pb.ChaincodeDeploymentSpec, error)

InitFromFS returns the chaincode and its package from the file system

func (*CDSPackage) PutChaincodeToFS Uses

func (ccpack *CDSPackage) PutChaincodeToFS() error

PutChaincodeToFS - serializes chaincode to a package on the file system

func (*CDSPackage) ValidateCC Uses

func (ccpack *CDSPackage) ValidateCC(ccdata *ChaincodeData) error

ValidateCC returns error if the chaincode is not found or if its not a ChaincodeDeploymentSpec

type ChaincodeData Uses

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 specific (see CDSPackage and SignedCDSPackage)

func GetChaincodeData Uses

func GetChaincodeData(ccNameVersion string) (*ChaincodeData, error)

GetChaincodeData gets chaincode data from cache if there's one

func (*ChaincodeData) ChaincodeID Uses

func (cd *ChaincodeData) ChaincodeID() string

ChaincodeID is the name by which the chaincode will register itself.

func (*ChaincodeData) ProtoMessage Uses

func (*ChaincodeData) ProtoMessage()

ProtoMessage just exists to make proto happy

func (*ChaincodeData) Reset Uses

func (cd *ChaincodeData) Reset()

Reset resets

func (*ChaincodeData) String Uses

func (cd *ChaincodeData) String() string

String converts to string

type ChaincodeExtractor Uses

type ChaincodeExtractor func(ccNameVersion string, path string, getHasher GetHasher) (CCPackage, error)

ChaincodeExtractor extracts chaincode from a given path

type DirEnumerator Uses

type DirEnumerator func(string) ([]os.FileInfo, error)

DirEnumerator enumerates directories

type GetHasher Uses

type GetHasher interface {
    GetHash(opts bccsp.HashOpts) (h hash.Hash, err error)
}

GetHasher interface defines a subset of bccsp which contains GetHash function.

type PersistenceAdapter Uses

type PersistenceAdapter func([]byte) ([]byte, error)

func (PersistenceAdapter) GetDBArtifacts Uses

func (pa PersistenceAdapter) GetDBArtifacts(codePackage []byte) ([]byte, error)

type SignedCDSData Uses

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 Uses

func (data *SignedCDSData) Equals(other *SignedCDSData) bool

Equals data equals other

func (*SignedCDSData) ProtoMessage Uses

func (*SignedCDSData) ProtoMessage()

ProtoMessage just exists to make proto happy

func (*SignedCDSData) Reset Uses

func (data *SignedCDSData) Reset()

Reset resets

func (*SignedCDSData) String Uses

func (data *SignedCDSData) String() string

String converts to string

type SignedCDSPackage Uses

type SignedCDSPackage struct {
    GetHasher GetHasher
    // contains filtered or unexported fields
}

SignedCDSPackage encapsulates SignedChaincodeDeploymentSpec.

func (*SignedCDSPackage) GetChaincodeData Uses

func (ccpack *SignedCDSPackage) GetChaincodeData() *ChaincodeData

GetChaincodeData gets the ChaincodeData

func (*SignedCDSPackage) GetDepSpec Uses

func (ccpack *SignedCDSPackage) GetDepSpec() *pb.ChaincodeDeploymentSpec

GetDepSpec gets the ChaincodeDeploymentSpec from the package

func (*SignedCDSPackage) GetDepSpecBytes Uses

func (ccpack *SignedCDSPackage) GetDepSpecBytes() []byte

GetDepSpecBytes gets the serialized ChaincodeDeploymentSpec from the package

func (*SignedCDSPackage) GetId Uses

func (ccpack *SignedCDSPackage) GetId() []byte

GetId gets the fingerprint of the chaincode based on package computation

func (*SignedCDSPackage) GetInstantiationPolicy Uses

func (ccpack *SignedCDSPackage) GetInstantiationPolicy() []byte

GetInstantiationPolicy gets the instantiation policy from the package

func (*SignedCDSPackage) GetPackageObject Uses

func (ccpack *SignedCDSPackage) GetPackageObject() proto.Message

GetPackageObject gets the ChaincodeDeploymentSpec as proto.Message

func (*SignedCDSPackage) InitFromBuffer Uses

func (ccpack *SignedCDSPackage) InitFromBuffer(buf []byte) (*ChaincodeData, error)

InitFromBuffer sets the buffer if valid and returns ChaincodeData

func (*SignedCDSPackage) InitFromFS Uses

func (ccpack *SignedCDSPackage) InitFromFS(ccNameVersion string) ([]byte, *pb.ChaincodeDeploymentSpec, error)

InitFromFS returns the chaincode and its package from the file system

func (*SignedCDSPackage) InitFromPath Uses

func (ccpack *SignedCDSPackage) InitFromPath(ccNameVersion string, path string) ([]byte, *pb.ChaincodeDeploymentSpec, error)

InitFromPath returns the chaincode and its package from the file system

func (*SignedCDSPackage) PutChaincodeToFS Uses

func (ccpack *SignedCDSPackage) PutChaincodeToFS() error

PutChaincodeToFS - serializes chaincode to a package on the file system

func (*SignedCDSPackage) ValidateCC Uses

func (ccpack *SignedCDSPackage) ValidateCC(ccdata *ChaincodeData) error

ValidateCC returns error if the chaincode is not found or if its not a ChaincodeDeploymentSpec

type TarFileEntry Uses

type TarFileEntry struct {
    FileHeader  *tar.Header
    FileContent []byte
}

tarFileEntry encapsulates a file entry and it's contents inside a tar

type TransactionParams Uses

type TransactionParams struct {
    TxID                 string
    ChannelID            string
    NamespaceID          string
    SignedProp           *pb.SignedProposal
    Proposal             *pb.Proposal
    TXSimulator          ledger.TxSimulator
    HistoryQueryExecutor ledger.HistoryQueryExecutor
    CollectionStore      privdata.CollectionStore
    IsInitTransaction    bool

    // this is additional data passed to the chaincode
    ProposalDecorations map[string][]byte
}

TransactionParams are parameters which are tied to a particular transaction and which are required for invoking chaincode.

Package ccprovider imports 23 packages (graph) and is imported by 90 packages. Updated 2019-11-15. Refresh now. Tools for package owners.