lifecycle

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NamespacesName is the prefix (or namespace) of the DB which will be used to store
	// the information about other namespaces (for things like chaincodes) in the DB.
	// We want a sub-namespaces within lifecycle in case other information needs to be stored here
	// in the future.
	NamespacesName = "namespaces"

	// ChaincodeSourcesName is the namespace reserved for storing the information about where
	// to find the chaincode (such as as a package on the local filesystem, or in the future,
	// at some network resource). This namespace is only populated in the org implicit collection.
	ChaincodeSourcesName = "chaincode-sources"

	// ChaincodeLocalPackageType is the name of the type of chaincode-sources which may be serialized
	// into the org's private data collection
	ChaincodeLocalPackageType = "ChaincodeLocalPackage"

	// ChaincodeParametersType is the name of the type used to store the parts of the chaincode definition
	// which are serialized as values in the statedb
	ChaincodeParametersType = "ChaincodeParameters"

	// ChaincodeDefinitionType is the name of the type used to store defined chaincodes
	ChaincodeDefinitionType = "ChaincodeDefinition"

	// FriendlyChaincodeDefinitionType is the name exposed to the outside world for the chaincode namespace
	FriendlyChaincodeDefinitionType = "Chaincode"

	// DefaultEndorsementPolicyRef is the name of the default endorsement policy for this channel
	DefaultEndorsementPolicyRef = "/Channel/Application/Endorsement"
)
View Source
const (
	// LifecycleNamespace is the namespace in the statedb where lifecycle
	// information is stored
	LifecycleNamespace = "_lifecycle"

	// InstallChaincodeFuncName is the chaincode function name used to install
	// a chaincode
	InstallChaincodeFuncName = "InstallChaincode"

	// QueryInstalledChaincodeFuncName is the chaincode function name used to
	// query an installed chaincode
	QueryInstalledChaincodeFuncName = "QueryInstalledChaincode"

	// QueryInstalledChaincodesFuncName is the chaincode function name used to
	// query all installed chaincodes
	QueryInstalledChaincodesFuncName = "QueryInstalledChaincodes"

	// ApproveChaincodeDefinitionForMyOrgFuncName is the chaincode function name
	// used to approve a chaincode definition for execution by the user's own org
	ApproveChaincodeDefinitionForMyOrgFuncName = "ApproveChaincodeDefinitionForMyOrg"

	// QueryApprovedChaincodeDefinitionFuncName is the chaincode function name used to
	// query a approved chaincode definition for the user's own org
	QueryApprovedChaincodeDefinitionFuncName = "QueryApprovedChaincodeDefinition"

	// CheckCommitReadinessFuncName is the chaincode function name used to check
	// a specified chaincode definition is ready to be committed. It returns the
	// approval status for a given definition over a given set of orgs
	CheckCommitReadinessFuncName = "CheckCommitReadiness"

	// CommitChaincodeDefinitionFuncName is the chaincode function name used to
	// 'commit' (previously 'instantiate') a chaincode in a channel.
	CommitChaincodeDefinitionFuncName = "CommitChaincodeDefinition"

	// QueryChaincodeDefinitionFuncName is the chaincode function name used to
	// query a committed chaincode definition in a channel.
	QueryChaincodeDefinitionFuncName = "QueryChaincodeDefinition"

	// QueryChaincodeDefinitionsFuncName is the chaincode function name used to
	// query the committed chaincode definitions in a channel.
	QueryChaincodeDefinitionsFuncName = "QueryChaincodeDefinitions"
)
View Source
const (
	MetadataInfix = "metadata"
	FieldsInfix   = "fields"
)
View Source
const (
	LifecycleEndorsementPolicyRef = "/Channel/Application/LifecycleEndorsement"
)

Variables

View Source
var (
	// NOTE the chaincode name/version regular expressions should stay in sync
	// with those defined in core/scc/lscc/lscc.go until LSCC has been removed.
	ChaincodeNameRegExp    = regexp.MustCompile("^[a-zA-Z0-9]+([-_][a-zA-Z0-9]+)*$")
	ChaincodeVersionRegExp = regexp.MustCompile("^[A-Za-z0-9_.+-]+$")
)
View Source
var (
	DefaultEndorsementPolicyBytes = protoutil.MarshalOrPanic(&pb.ApplicationPolicy{
		Type: &pb.ApplicationPolicy_ChannelConfigPolicyReference{
			ChannelConfigPolicyReference: DefaultEndorsementPolicyRef,
		},
	})
)
View Source
var ImplicitCollectionMatcher = regexp.MustCompile("^" + ImplicitCollectionNameForOrg("(.+)") + "$")
View Source
var (
	// This is a channel which was created with a lifecycle endorsement policy
	LifecycleDefaultEndorsementPolicyBytes = protoutil.MarshalOrPanic(&cb.ApplicationPolicy{
		Type: &cb.ApplicationPolicy_ChannelConfigPolicyReference{
			ChannelConfigPolicyReference: LifecycleEndorsementPolicyRef,
		},
	})
)
View Source
var ProtoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem()
View Source
var SequenceMatcher = regexp.MustCompile("^" + NamespacesName + "/fields/([^/]+)/Sequence$")

Functions

func FieldKey added in v1.5.6

func FieldKey(namespace, name, field string) string

func ImplicitCollectionNameForOrg added in v1.5.6

func ImplicitCollectionNameForOrg(mspid string) string

func MetadataKey added in v1.5.6

func MetadataKey(namespace, name string) string

func OrgFromImplicitCollectionName added in v1.5.6

func OrgFromImplicitCollectionName(name string) string

func StateIteratorToMap added in v1.5.6

func StateIteratorToMap(itr StateIterator) (map[string][]byte, error)

StateIteratorToMap takes an iterator, and iterates over the entire thing, encoding the KVs into a map, and then closes it.

Types

type ApprovedChaincodeDefinition added in v1.5.6

type ApprovedChaincodeDefinition struct {
	Sequence        int64
	EndorsementInfo *lb.ChaincodeEndorsementInfo
	ValidationInfo  *lb.ChaincodeValidationInfo
	Collections     *pb.CollectionConfigPackage
	Source          *lb.ChaincodeSource
}

type Cache added in v1.5.6

type Cache struct {
	Resources  *Resources
	MyOrgMSPID string

	MetadataHandler MetadataHandler
	// contains filtered or unexported fields
}

func NewCache added in v1.5.6

func NewCache(resources *Resources, myOrgMSPID string, metadataManager MetadataHandler, custodian *ChaincodeCustodian, ebMetadata *externalbuilder.MetadataProvider) *Cache

func (*Cache) ChaincodeInfo added in v1.5.6

func (c *Cache) ChaincodeInfo(channelID, name string) (*LocalChaincodeInfo, error)

ChaincodeInfo returns the chaincode definition and its install info. An error is returned only if either the channel or the chaincode do not exist.

func (*Cache) GetInstalledChaincode added in v1.5.6

func (c *Cache) GetInstalledChaincode(packageID string) (*chaincode.InstalledChaincode, error)

GetInstalledChaincode returns all of the information about a specific installed chaincode.

func (*Cache) HandleChaincodeInstalled added in v1.5.6

func (c *Cache) HandleChaincodeInstalled(md *persistence.ChaincodePackageMetadata, packageID string)

HandleChaincodeInstalled should be invoked whenever a new chaincode is installed

func (*Cache) HandleStateUpdates added in v1.5.6

func (c *Cache) HandleStateUpdates(trigger *ledger.StateUpdateTrigger) error

HandleStateUpdates is required to implement the ledger state listener interface. It applies any state updates to the cache.

func (*Cache) Initialize added in v1.5.6

func (c *Cache) Initialize(channelID string, qe ledger.SimpleQueryExecutor) error

Initialize will populate the set of currently committed chaincode definitions for a channel into the cache. Note, it this looks like a bit of a DRY violation with respect to 'Update', but, the error handling is quite different and attempting to factor out the common pieces results in a net total of more code.

func (*Cache) InitializeLocalChaincodes added in v1.5.6

func (c *Cache) InitializeLocalChaincodes() error

InitializeLocalChaincodes should be called once after cache creation (timing doesn't matter, though already installed chaincodes will not be invokable until it it completes). Ideally, this would be part of the constructor, but, we cannot rely on the chaincode store being created before the cache is created.

func (*Cache) InitializeMetadata added in v1.5.6

func (c *Cache) InitializeMetadata(channel string)

func (*Cache) InterestedInNamespaces added in v1.5.6

func (c *Cache) InterestedInNamespaces() []string

InterestedInNamespaces is required to implement the ledger state listener interface

func (*Cache) ListInstalledChaincodes added in v1.5.6

func (c *Cache) ListInstalledChaincodes() []*chaincode.InstalledChaincode

ListInstalledChaincodes returns a slice containing all of the information about the installed chaincodes.

func (*Cache) Name added in v1.5.6

func (c *Cache) Name() string

Name returns the name of the listener

func (*Cache) RegisterListener added in v1.5.6

func (c *Cache) RegisterListener(channelID string, listener ledger.ChaincodeLifecycleEventListener)

RegisterListener registers an event listener for receiving an event when a chaincode becomes invokable

func (*Cache) StateCommitDone added in v1.5.6

func (c *Cache) StateCommitDone(channelName string)

StateCommitDone is required to implement the ledger state listener interface

type CachedChaincodeDefinition added in v1.5.6

type CachedChaincodeDefinition struct {
	Definition  *ChaincodeDefinition
	Approved    bool
	InstallInfo *ChaincodeInstallInfo

	// Hashes is the list of hashed keys in the implicit collection referring to this definition.
	// These hashes are determined by the current sequence number of chaincode definition.  When dirty,
	// these hashes will be empty, and when not, they will be populated.
	Hashes []string
}

type ChaincodeBuilder added in v1.5.6

type ChaincodeBuilder interface {
	Build(ccid string) error
}

type ChaincodeCustodian added in v1.5.6

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

ChaincodeCustodian is responsible for enqueuing builds and launches of chaincodes as they become available and stops when chaincodes are no longer referenced by an active chaincode definition.

func NewChaincodeCustodian added in v1.5.6

func NewChaincodeCustodian() *ChaincodeCustodian

NewChaincodeCustodian creates an instance of a chaincode custodian. It is the instantiator's responsibility to spawn a go routine to service the Work routine along with the appropriate dependencies.

func (*ChaincodeCustodian) Close added in v1.5.6

func (cc *ChaincodeCustodian) Close()

func (*ChaincodeCustodian) NotifyInstalled added in v1.5.6

func (cc *ChaincodeCustodian) NotifyInstalled(chaincodeID string)

func (*ChaincodeCustodian) NotifyInstalledAndRunnable added in v1.5.6

func (cc *ChaincodeCustodian) NotifyInstalledAndRunnable(chaincodeID string)

func (*ChaincodeCustodian) NotifyStoppable added in v1.5.6

func (cc *ChaincodeCustodian) NotifyStoppable(chaincodeID string)

func (*ChaincodeCustodian) Work added in v1.5.6

func (cc *ChaincodeCustodian) Work(buildRegistry *container.BuildRegistry, builder ChaincodeBuilder, launcher ChaincodeLauncher)

type ChaincodeDefinition added in v1.5.6

type ChaincodeDefinition struct {
	Sequence        int64
	EndorsementInfo *lb.ChaincodeEndorsementInfo
	ValidationInfo  *lb.ChaincodeValidationInfo
	Collections     *pb.CollectionConfigPackage
}

ChaincodeDefinition contains the chaincode parameters, as well as the sequence number of the definition. Note, it does not embed ChaincodeParameters so as not to complicate the serialization. It is expected that any instance will have no nil fields once initialized. WARNING: This structure is serialized/deserialized from the DB, re-ordering or adding fields will cause opaque checks to fail.

func (*ChaincodeDefinition) Parameters added in v1.5.6

func (cd *ChaincodeDefinition) Parameters() *ChaincodeParameters

Parameters returns the non-sequence info of the chaincode definition

func (*ChaincodeDefinition) String added in v1.5.6

func (cd *ChaincodeDefinition) String() string

type ChaincodeEndorsementInfo added in v1.5.6

type ChaincodeEndorsementInfo struct {
	// Version is the version from the definition in this particular channel and namespace context.
	Version string

	// EnforceInit is set to true for definitions which require the chaincode package to enforce
	// 'init exactly once' semantics.
	EnforceInit bool

	// ChaincodeID is the name by which to look up or launch the underlying chaincode.
	ChaincodeID string

	// EndorsementPlugin is the name of the plugin to use when endorsing.
	EndorsementPlugin string
}

ChaincodeEndorsementInfo contains the information necessary to handle a chaincode invoke request.

type ChaincodeEndorsementInfoSource added in v1.5.6

type ChaincodeEndorsementInfoSource struct {
	Resources   *Resources
	Cache       ChaincodeInfoCache
	LegacyImpl  Lifecycle
	BuiltinSCCs scc.BuiltinSCCs
	UserRunsCC  bool
}

func (*ChaincodeEndorsementInfoSource) CachedChaincodeInfo added in v1.5.6

func (cei *ChaincodeEndorsementInfoSource) CachedChaincodeInfo(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (*LocalChaincodeInfo, bool, error)

func (*ChaincodeEndorsementInfoSource) ChaincodeEndorsementInfo added in v1.5.6

func (cei *ChaincodeEndorsementInfoSource) ChaincodeEndorsementInfo(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (*ChaincodeEndorsementInfo, error)

ChaincodeEndorsementInfo returns the information necessary to handle a chaincode invocation request, as well as a function to enforce security checks on the chaincode (in case the definition is from the legacy lscc).

type ChaincodeInfoCache added in v1.5.6

type ChaincodeInfoCache interface {
	ChaincodeInfo(channelID, chaincodeName string) (definition *LocalChaincodeInfo, err error)
}

type ChaincodeInfoProvider added in v1.5.6

type ChaincodeInfoProvider interface {
	// ChaincodeInfo returns the chaincode definition and its install info.
	// An error is returned only if either the channel or the chaincode do not exist.
	ChaincodeInfo(channelID, name string) (*LocalChaincodeInfo, error)
}

ChaincodeInfoProvider provides metadata for a _lifecycle-defined chaincode on a specific channel

type ChaincodeInstallInfo added in v1.5.6

type ChaincodeInstallInfo struct {
	PackageID string
	Type      string
	Path      string
	Label     string
}

type ChaincodeLauncher added in v1.5.6

type ChaincodeLauncher interface {
	Launch(ccid string) error
	Stop(ccid string) error
}

type ChaincodeLocalPackage added in v1.5.6

type ChaincodeLocalPackage struct {
	PackageID string
}

ChaincodeLocalPackage is a type of chaincode-sources which may be serialized into the org's private data collection. WARNING: This structure is serialized/deserialized from the DB, re-ordering or adding fields will cause opaque checks to fail.

type ChaincodeParameters added in v1.5.6

type ChaincodeParameters struct {
	EndorsementInfo *lb.ChaincodeEndorsementInfo
	ValidationInfo  *lb.ChaincodeValidationInfo
	Collections     *pb.CollectionConfigPackage
}

ChaincodeParameters are the parts of the chaincode definition which are serialized as values in the statedb. It is expected that any instance will have no nil fields once initialized. WARNING: This structure is serialized/deserialized from the DB, re-ordering or adding fields will cause opaque checks to fail.

func (*ChaincodeParameters) Equal added in v1.5.6

type ChaincodePrivateLedgerShim added in v1.5.6

type ChaincodePrivateLedgerShim struct {
	Stub       shim.ChaincodeStubInterface
	Collection string
}

ChaincodePrivateLedgerShim wraps the chaincode shim to make access to keys in a collection have the same semantics as normal public keys.

func (*ChaincodePrivateLedgerShim) CollectionName added in v1.5.6

func (cls *ChaincodePrivateLedgerShim) CollectionName() string

func (*ChaincodePrivateLedgerShim) DelState added in v1.5.6

func (cls *ChaincodePrivateLedgerShim) DelState(key string) error

DelState deletes the key in the configured collection.

func (*ChaincodePrivateLedgerShim) GetState added in v1.5.6

func (cls *ChaincodePrivateLedgerShim) GetState(key string) ([]byte, error)

GetState returns the value for the key in the configured collection.

func (*ChaincodePrivateLedgerShim) GetStateHash added in v1.5.6

func (cls *ChaincodePrivateLedgerShim) GetStateHash(key string) ([]byte, error)

GetStateHash return the hash of the pre-image for the key in the configured collection.

func (*ChaincodePrivateLedgerShim) GetStateRange added in v1.5.6

func (cls *ChaincodePrivateLedgerShim) GetStateRange(prefix string) (map[string][]byte, error)

GetStateRange performs a range query in the configured collection for all keys beginning with a particular prefix. This function assumes that keys contain only ascii chars from \x00 to \x7e.

func (*ChaincodePrivateLedgerShim) PutState added in v1.5.6

func (cls *ChaincodePrivateLedgerShim) PutState(key string, value []byte) error

PutState sets the value for the key in the configured collection.

type ChaincodePublicLedgerShim added in v1.5.6

type ChaincodePublicLedgerShim struct {
	shim.ChaincodeStubInterface
}

ChaincodePublicLedgerShim decorates the chaincode shim to support the state interfaces required by the serialization code.

func (*ChaincodePublicLedgerShim) GetStateRange added in v1.5.6

func (cls *ChaincodePublicLedgerShim) GetStateRange(prefix string) (map[string][]byte, error)

GetStateRange performs a range query for keys beginning with a particular prefix, and returns it as a map. This function assumes that keys contain only ascii chars from \x00 to \x7e.

type ChaincodeResultIteratorShim added in v1.5.6

type ChaincodeResultIteratorShim struct {
	ResultsIterator shim.StateQueryIteratorInterface
}

func (*ChaincodeResultIteratorShim) Close added in v1.5.6

func (cris *ChaincodeResultIteratorShim) Close() error

func (*ChaincodeResultIteratorShim) Next added in v1.5.6

type ChaincodeStore

type ChaincodeStore interface {
	Save(label string, ccInstallPkg []byte) (string, error)
	ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error)
	Load(packageID string) (ccInstallPkg []byte, err error)
	Delete(packageID string) error
}

ChaincodeStore provides a way to persist chaincodes

type ChannelCache added in v1.5.6

type ChannelCache struct {
	Chaincodes map[string]*CachedChaincodeDefinition

	// InterestingHashes is a map of hashed key names to the chaincode name which they affect.
	// These are to be used for the state listener, to mark chaincode definitions dirty when
	// a write is made into the implicit collection for this org.  Interesting hashes are
	// added when marking a definition clean, and deleted when marking it dirty.
	InterestingHashes map[string]string
}

type ChannelConfigSource added in v1.5.6

type ChannelConfigSource interface {
	// GetStableChannelConfig returns the channel config for a given channel id.
	// Note, it is a stable bundle, which means it will not be updated, even if
	// the channel is, so it should be discarded after use.
	GetStableChannelConfig(channelID string) channelconfig.Resources
}

ChannelConfigSource provides a way to retrieve the channel config for a given channel ID.

type ChannelPolicyReferenceProvider added in v1.5.6

type ChannelPolicyReferenceProvider interface {
	// NewPolicy creates a new policy based on the policy bytes
	NewPolicy(channelID, channelConfigPolicyReference string) (policies.Policy, error)
}

ChannelPolicyReferenceProvider is used to determine if a set of signature is valid and complies with a policy

type DummyQueryExecutorShim added in v1.5.6

type DummyQueryExecutorShim struct {
}

DummyQueryExecutorShim implements the ReadableState interface. It is used to ensure channel-less system chaincode calls don't panic and return and error when an invalid operation is attempted (i.e. an InstallChaincode invocation against a chaincode other than _lifecycle)

func (*DummyQueryExecutorShim) GetState added in v1.5.6

func (*DummyQueryExecutorShim) GetState(key string) ([]byte, error)

type ErrNamespaceNotDefined added in v1.5.6

type ErrNamespaceNotDefined struct {
	Namespace string
}

ErrNamespaceNotDefined is the error returned when a namespace is not defined. This indicates that the chaincode definition has not been committed.

func (ErrNamespaceNotDefined) Error added in v1.5.6

func (e ErrNamespaceNotDefined) Error() string

type EventBroker added in v1.5.6

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

EventBroker receives events from lifecycle cache and in turn invokes the registered listeners

func NewEventBroker added in v1.5.6

func NewEventBroker(chaincodeStore ChaincodeStore, pkgParser PackageParser, ebMetadata *externalbuilder.MetadataProvider) *EventBroker

func (*EventBroker) ApproveOrDefineCommitted added in v1.5.6

func (b *EventBroker) ApproveOrDefineCommitted(channelID string)

ApproveOrDefineCommitted gets invoked after the commit of state updates that triggered the invocation of "ProcessApproveOrDefineEvent" function

func (*EventBroker) ProcessApproveOrDefineEvent added in v1.5.6

func (b *EventBroker) ProcessApproveOrDefineEvent(channelID string, chaincodeName string, cachedChaincode *CachedChaincodeDefinition)

ProcessApproveOrDefineEvent gets invoked by an event that makes approve and define to be true This should be OK even if this function gets invoked on defined and approved events separately because the first check in this function evaluates the final condition. However, the current cache implementation invokes this function when approve and define both become true.

func (*EventBroker) ProcessInstallEvent added in v1.5.6

func (b *EventBroker) ProcessInstallEvent(localChaincode *LocalChaincode)

ProcessInstallEvent gets invoked when a chaincode is installed

func (*EventBroker) RegisterListener added in v1.5.6

func (b *EventBroker) RegisterListener(channelID string, listener ledger.ChaincodeLifecycleEventListener)

type ExternalFunctions added in v1.5.6

type ExternalFunctions struct {
	Resources                 *Resources
	InstallListener           InstallListener
	InstalledChaincodesLister InstalledChaincodesLister
	ChaincodeBuilder          ChaincodeBuilder
	BuildRegistry             *container.BuildRegistry

	BuildLocks map[string]sync.Mutex
	// contains filtered or unexported fields
}

ExternalFunctions is intended primarily to support the SCC functions. In general, its methods signatures produce writes (which must be commmitted as part of an endorsement flow), or return human readable errors (for instance indicating a chaincode is not found) rather than sentinels. Instead, use the utility functions attached to the lifecycle Resources when needed.

func (*ExternalFunctions) ApproveChaincodeDefinitionForOrg added in v1.5.6

func (ef *ExternalFunctions) ApproveChaincodeDefinitionForOrg(chname, ccname string, cd *ChaincodeDefinition, packageID string, publicState ReadableState, orgState ReadWritableState) error

ApproveChaincodeDefinitionForOrg adds a chaincode definition entry into the passed in Org state. The definition must be for either the currently defined sequence number or the next sequence number. If the definition is for the current sequence number, then it must match exactly the current definition or it will be rejected.

func (*ExternalFunctions) CheckCommitReadiness added in v1.5.6

func (ef *ExternalFunctions) CheckCommitReadiness(chname, ccname string, cd *ChaincodeDefinition, publicState ReadWritableState, orgStates []OpaqueState) (map[string]bool, error)

CheckCommitReadiness takes a chaincode definition, checks that its sequence number is the next allowable sequence number and checks which organizations have approved the definition.

func (*ExternalFunctions) CommitChaincodeDefinition added in v1.5.6

func (ef *ExternalFunctions) CommitChaincodeDefinition(chname, ccname string, cd *ChaincodeDefinition, publicState ReadWritableState, orgStates []OpaqueState) (map[string]bool, error)

CommitChaincodeDefinition takes a chaincode definition, checks that its sequence number is the next allowable sequence number, checks which organizations have approved the definition, and applies the definition to the public world state. It is the responsibility of the caller to check the approvals to determine if the result is valid (typically, this means checking that the peer's own org has approved the definition).

func (*ExternalFunctions) DefaultEndorsementPolicyAsBytes added in v1.5.6

func (ef *ExternalFunctions) DefaultEndorsementPolicyAsBytes(channelID string) ([]byte, error)

DefaultEndorsementPolicyAsBytes returns a marshalled version of the default chaincode endorsement policy in the supplied channel

func (*ExternalFunctions) GetInstalledChaincodePackage added in v1.5.6

func (ef *ExternalFunctions) GetInstalledChaincodePackage(packageID string) ([]byte, error)

GetInstalledChaincodePackage retrieves the installed chaincode with the given package ID from the peer's chaincode store.

func (*ExternalFunctions) InstallChaincode added in v1.5.6

func (ef *ExternalFunctions) InstallChaincode(chaincodeInstallPackage []byte) (*chaincode.InstalledChaincode, error)

InstallChaincode installs a given chaincode to the peer's chaincode store. It returns the hash to reference the chaincode by or an error on failure.

func (*ExternalFunctions) QueryApprovedChaincodeDefinition added in v1.5.6

func (ef *ExternalFunctions) QueryApprovedChaincodeDefinition(chname, ccname string, sequence int64, publicState ReadableState, orgState ReadableState) (*ApprovedChaincodeDefinition, error)

QueryApprovedChaincodeDefinition returns the approved chaincode definition in Org state by using the given parameters. If the parameter of sequence is not provided, this function returns the latest approved chaincode definition (latest: new one of the currently defined sequence number and the next sequence number).

func (*ExternalFunctions) QueryChaincodeDefinition added in v1.5.6

func (ef *ExternalFunctions) QueryChaincodeDefinition(name string, publicState ReadableState) (*ChaincodeDefinition, error)

QueryChaincodeDefinition returns the defined chaincode by the given name (if it is committed, and a chaincode) or otherwise returns an error.

func (*ExternalFunctions) QueryInstalledChaincode added in v1.5.6

func (ef *ExternalFunctions) QueryInstalledChaincode(packageID string) (*chaincode.InstalledChaincode, error)

QueryInstalledChaincode returns metadata for the chaincode with the supplied package ID.

func (*ExternalFunctions) QueryInstalledChaincodes added in v1.5.6

func (ef *ExternalFunctions) QueryInstalledChaincodes() []*chaincode.InstalledChaincode

QueryInstalledChaincodes returns a list of installed chaincodes

func (*ExternalFunctions) QueryNamespaceDefinitions added in v1.5.6

func (ef *ExternalFunctions) QueryNamespaceDefinitions(publicState RangeableState) (map[string]string, error)

QueryNamespaceDefinitions lists the publicly defined namespaces in a channel. Today it should only ever find Datatype encodings of 'ChaincodeDefinition'.

func (*ExternalFunctions) QueryOrgApprovals added in v1.5.6

func (ef *ExternalFunctions) QueryOrgApprovals(name string, cd *ChaincodeDefinition, orgStates []OpaqueState) (map[string]bool, error)

QueryOrgApprovals returns a map containing the orgs whose orgStates were provided and whether or not they have approved a chaincode definition with the specified parameters.

func (*ExternalFunctions) SetChaincodeDefinitionDefaults added in v1.5.6

func (ef *ExternalFunctions) SetChaincodeDefinitionDefaults(chname string, cd *ChaincodeDefinition) error

SetChaincodeDefinitionDefaults fills any empty fields in the supplied ChaincodeDefinition with the supplied channel's defaults

type HandleMetadataUpdateFunc added in v1.5.6

type HandleMetadataUpdateFunc func(channel string, metadata chaincode.MetadataSet)

HandleMetadataUpdateFunc is triggered upon a change in the chaincode lifecycle.

func (HandleMetadataUpdateFunc) HandleMetadataUpdate added in v1.5.6

func (handleMetadataUpdate HandleMetadataUpdateFunc) HandleMetadataUpdate(channel string, metadata chaincode.MetadataSet)

HandleMetadataUpdate runs whenever there is a change to the metadata of a chaincode in the context of a specific channel.

type InstallListener added in v1.5.6

type InstallListener interface {
	HandleChaincodeInstalled(md *persistence.ChaincodePackageMetadata, packageID string)
}

type InstalledChaincodesLister added in v1.5.6

type InstalledChaincodesLister interface {
	ListInstalledChaincodes() []*chaincode.InstalledChaincode
	GetInstalledChaincode(packageID string) (*chaincode.InstalledChaincode, error)
}

type Invocation added in v1.5.6

type Invocation struct {
	ChannelID         string
	ApplicationConfig channelconfig.Application // Note this may be nil
	Stub              shim.ChaincodeStubInterface
	SCC               *SCC
}

func (*Invocation) ApproveChaincodeDefinitionForMyOrg added in v1.5.6

func (i *Invocation) ApproveChaincodeDefinitionForMyOrg(input *lb.ApproveChaincodeDefinitionForMyOrgArgs) (proto.Message, error)

ApproveChaincodeDefinitionForMyOrg is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) CheckCommitReadiness added in v1.5.6

func (i *Invocation) CheckCommitReadiness(input *lb.CheckCommitReadinessArgs) (proto.Message, error)

CheckCommitReadiness is a SCC function that may be dispatched to the underlying lifecycle implementation.

func (*Invocation) CommitChaincodeDefinition added in v1.5.6

func (i *Invocation) CommitChaincodeDefinition(input *lb.CommitChaincodeDefinitionArgs) (proto.Message, error)

CommitChaincodeDefinition is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) GetInstalledChaincodePackage added in v1.5.6

func (i *Invocation) GetInstalledChaincodePackage(input *lb.GetInstalledChaincodePackageArgs) (proto.Message, error)

GetInstalledChaincodePackage is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) InstallChaincode added in v1.5.6

func (i *Invocation) InstallChaincode(input *lb.InstallChaincodeArgs) (proto.Message, error)

InstallChaincode is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) QueryApprovedChaincodeDefinition added in v1.5.6

func (i *Invocation) QueryApprovedChaincodeDefinition(input *lb.QueryApprovedChaincodeDefinitionArgs) (proto.Message, error)

QueryApprovedChaincodeDefinition is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) QueryChaincodeDefinition added in v1.5.6

func (i *Invocation) QueryChaincodeDefinition(input *lb.QueryChaincodeDefinitionArgs) (proto.Message, error)

QueryChaincodeDefinition is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) QueryChaincodeDefinitions added in v1.5.6

func (i *Invocation) QueryChaincodeDefinitions(input *lb.QueryChaincodeDefinitionsArgs) (proto.Message, error)

QueryChaincodeDefinitions is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) QueryInstalledChaincode added in v1.5.6

func (i *Invocation) QueryInstalledChaincode(input *lb.QueryInstalledChaincodeArgs) (proto.Message, error)

QueryInstalledChaincode is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

func (*Invocation) QueryInstalledChaincodes added in v1.5.6

func (i *Invocation) QueryInstalledChaincodes(input *lb.QueryInstalledChaincodesArgs) (proto.Message, error)

QueryInstalledChaincodes is a SCC function that may be dispatched to which routes to the underlying lifecycle implementation.

type LegacyDeployedCCInfoProvider added in v1.5.6

type LegacyDeployedCCInfoProvider interface {
	ledger.DeployedChaincodeInfoProvider
}

type LegacyMetadataProvider added in v1.5.6

type LegacyMetadataProvider interface {
	Metadata(channel string, cc string, collections ...string) *chaincode.Metadata
}

LegacyMetadataProvider provides metadata for a lscc-defined chaincode on a specific channel.

type Lifecycle

type Lifecycle interface {
	ChaincodeEndorsementInfo(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (*ChaincodeEndorsementInfo, error)
}

Lifecycle is the interface which the core/chaincode package and core/endorser package requires that lifecycle satisfy.

type LocalChaincode added in v1.5.6

type LocalChaincode struct {
	Info       *ChaincodeInstallInfo
	References map[string]map[string]*CachedChaincodeDefinition
}

func (*LocalChaincode) ToInstalledChaincode added in v1.5.6

func (l *LocalChaincode) ToInstalledChaincode() *chaincode.InstalledChaincode

ToInstalledChaincode converts a LocalChaincode to an InstalledChaincode, which is returned by lifecycle queries.

type LocalChaincodeInfo added in v1.5.6

type LocalChaincodeInfo struct {
	Definition  *ChaincodeDefinition
	Approved    bool
	InstallInfo *ChaincodeInstallInfo
}

type Marshaler added in v1.5.6

type Marshaler func(proto.Message) ([]byte, error)

func (Marshaler) Marshal added in v1.5.6

func (m Marshaler) Marshal(msg proto.Message) ([]byte, error)

type MetadataHandler added in v1.5.6

type MetadataHandler interface {
	InitializeMetadata(channel string, chaincodes chaincode.MetadataSet)
	UpdateMetadata(channel string, chaincodes chaincode.MetadataSet)
}

MetadataHandler is the interface through which the cache drives metadata updates for listeners such as gossip and service discovery

type MetadataManager added in v1.5.6

type MetadataManager struct {
	LegacyMetadataSet map[string]chaincode.MetadataSet
	MetadataSet       map[string]chaincode.MetadataSet
	// contains filtered or unexported fields
}

MetadataManager stores metadata about the chaincodes installed/deployed via _lifecycle (Metadaset) and lscc (LegacyMetadataSet) and updates any registered listeners upon a change in the metadata.

func NewMetadataManager added in v1.5.6

func NewMetadataManager() *MetadataManager

func (*MetadataManager) AddListener added in v1.5.6

func (m *MetadataManager) AddListener(listener MetadataUpdateListener)

AddListener registers the given listener to be triggered upon a lifecycle change

func (*MetadataManager) HandleMetadataUpdate added in v1.5.6

func (m *MetadataManager) HandleMetadataUpdate(channel string, metadata chaincode.MetadataSet)

HandleMetadataUpdate implements the function of the same name in the cclifecycle.LifecycleChangeListener interface. This function is called by the legacy lifecycle (lscc) to deliver updates so we aggregate them and propagate them to our listeners. This function is also called to initialise data structures right at peer startup time.

func (*MetadataManager) InitializeMetadata added in v1.5.6

func (m *MetadataManager) InitializeMetadata(channel string, metadata chaincode.MetadataSet)

InitializeMetadata implements the function of the same name in the lifecycle.MetadataManager interface. This function is called by _lifecycle to initialize metadata for the given channel.

func (*MetadataManager) UpdateMetadata added in v1.5.6

func (m *MetadataManager) UpdateMetadata(channel string, metadata chaincode.MetadataSet)

UpdateMetadata implements the function of the same name in the lifecycle.MetadataManager interface. This function is called by _lifecycle to deliver updates so we aggregate them and propagate them to our listeners.

type MetadataProvider added in v1.5.6

type MetadataProvider struct {
	ChaincodeInfoProvider          ChaincodeInfoProvider
	LegacyMetadataProvider         LegacyMetadataProvider
	ChannelPolicyReferenceProvider ChannelPolicyReferenceProvider
}

func NewMetadataProvider added in v1.5.6

NewMetadataProvider returns a new MetadataProvider instance

func (*MetadataProvider) Metadata added in v1.5.6

func (mp *MetadataProvider) Metadata(channel string, ccName string, collections ...string) *chaincode.Metadata

Metadata implements the metadata retriever support interface for service discovery

type MetadataUpdateListener added in v1.5.6

type MetadataUpdateListener interface {
	HandleMetadataUpdate(channel string, metadata chaincode.MetadataSet)
}

MetadataUpdateListener runs whenever there is a change to the metadata of a chaincode in the context of a specific channel.

type OpaqueState added in v1.5.6

type OpaqueState interface {
	GetStateHash(key string) (value []byte, err error)
	CollectionName() string
}

type PackageParser

type PackageParser interface {
	Parse(data []byte) (*persistence.ChaincodePackage, error)
}

type PrivateQueryExecutor added in v1.5.6

type PrivateQueryExecutor interface {
	GetPrivateDataHash(namespace, collection, key string) (value []byte, err error)
}

type PrivateQueryExecutorShim added in v1.5.6

type PrivateQueryExecutorShim struct {
	Namespace  string
	Collection string
	State      PrivateQueryExecutor
}

func (*PrivateQueryExecutorShim) CollectionName added in v1.5.6

func (pqes *PrivateQueryExecutorShim) CollectionName() string

func (*PrivateQueryExecutorShim) GetStateHash added in v1.5.6

func (pqes *PrivateQueryExecutorShim) GetStateHash(key string) ([]byte, error)

type QueryExecutorProvider added in v1.5.6

type QueryExecutorProvider interface {
	TxQueryExecutor(channelID, txID string) ledger.SimpleQueryExecutor
}

QueryExecutorProvider provides a way to retrieve the query executor assosciated with an invocation

type RangeableState added in v1.5.6

type RangeableState interface {
	GetStateRange(prefix string) (map[string][]byte, error)
}

type ReadWritableState added in v1.5.6

type ReadWritableState interface {
	ReadableState
	PutState(key string, value []byte) error
	DelState(key string) error
}

type ReadableState added in v1.5.6

type ReadableState interface {
	GetState(key string) (value []byte, err error)
}

type Resources added in v1.5.6

type Resources struct {
	ChannelConfigSource ChannelConfigSource
	ChaincodeStore      ChaincodeStore
	PackageParser       PackageParser
	Serializer          *Serializer
}

Resources stores the common functions needed by all components of the lifecycle by the SCC as well as internally. It also has some utility methods attached to it for querying the lifecycle definitions.

func (*Resources) ChaincodeDefinitionIfDefined added in v1.5.6

func (r *Resources) ChaincodeDefinitionIfDefined(chaincodeName string, state ReadableState) (bool, *ChaincodeDefinition, error)

ChaincodeDefinitionIfDefined returns whether the chaincode name is defined in the new lifecycle, a shim around the SimpleQueryExecutor to work with the serializer, or an error. If the namespace is defined, but it is not a chaincode, this is considered an error.

func (*Resources) LifecycleEndorsementPolicyAsBytes added in v1.5.6

func (r *Resources) LifecycleEndorsementPolicyAsBytes(channelID string) ([]byte, error)

type ResultsIteratorShim added in v1.5.6

type ResultsIteratorShim struct {
	ResultsIterator commonledger.ResultsIterator
}

func (*ResultsIteratorShim) Close added in v1.5.6

func (ris *ResultsIteratorShim) Close() error

func (*ResultsIteratorShim) Next added in v1.5.6

func (ris *ResultsIteratorShim) Next() (*queryresult.KV, error)

type SCC

type SCC struct {
	OrgMSPID string

	ACLProvider aclmgmt.ACLProvider

	ChannelConfigSource ChannelConfigSource

	DeployedCCInfoProvider ledger.DeployedChaincodeInfoProvider
	QueryExecutorProvider  QueryExecutorProvider

	// Functions provides the backing implementation of lifecycle.
	Functions SCCFunctions

	// Dispatcher handles the rote protobuf boilerplate for unmarshaling/marshaling
	// the inputs and outputs of the SCC functions.
	Dispatcher *dispatcher.Dispatcher
}

SCC implements the required methods to satisfy the chaincode interface. It routes the invocation calls to the backing implementations.

func (*SCC) Chaincode

func (scc *SCC) Chaincode() shim.Chaincode

Chaincode returns a reference to itself

func (*SCC) Init

func (scc *SCC) Init(stub shim.ChaincodeStubInterface) pb.Response

Init is mostly useless for system chaincodes and always returns success

func (*SCC) Invoke

func (scc *SCC) Invoke(stub shim.ChaincodeStubInterface) pb.Response

Invoke takes chaincode invocation arguments and routes them to the correct underlying lifecycle operation. All functions take a single argument of type marshaled lb.<FunctionName>Args and return a marshaled lb.<FunctionName>Result

func (*SCC) Name

func (scc *SCC) Name() string

Name returns "_lifecycle"

type SCCFunctions added in v1.4.0

type SCCFunctions interface {
	// InstallChaincode persists a chaincode definition to disk
	InstallChaincode([]byte) (*chaincode.InstalledChaincode, error)

	// QueryInstalledChaincode returns metadata for the chaincode with the supplied package ID.
	QueryInstalledChaincode(packageID string) (*chaincode.InstalledChaincode, error)

	// GetInstalledChaincodePackage returns the chaincode package
	// installed on the peer as bytes.
	GetInstalledChaincodePackage(packageID string) ([]byte, error)

	// QueryInstalledChaincodes returns the currently installed chaincodes
	QueryInstalledChaincodes() []*chaincode.InstalledChaincode

	// ApproveChaincodeDefinitionForOrg records a chaincode definition into this org's implicit collection.
	ApproveChaincodeDefinitionForOrg(chname, ccname string, cd *ChaincodeDefinition, packageID string, publicState ReadableState, orgState ReadWritableState) error

	// QueryApprovedChaincodeDefinition returns a approved chaincode definition from this org's implicit collection.
	QueryApprovedChaincodeDefinition(chname, ccname string, sequence int64, publicState ReadableState, orgState ReadableState) (*ApprovedChaincodeDefinition, error)

	// CheckCommitReadiness returns a map containing the orgs
	// whose orgStates were supplied and whether or not they have approved
	// the specified definition.
	CheckCommitReadiness(chname, ccname string, cd *ChaincodeDefinition, publicState ReadWritableState, orgStates []OpaqueState) (map[string]bool, error)

	// CommitChaincodeDefinition records a new chaincode definition into the
	// public state and returns a map containing the orgs whose orgStates
	// were supplied and whether or not they have approved the definition.
	CommitChaincodeDefinition(chname, ccname string, cd *ChaincodeDefinition, publicState ReadWritableState, orgStates []OpaqueState) (map[string]bool, error)

	// QueryChaincodeDefinition returns a chaincode definition from the public
	// state.
	QueryChaincodeDefinition(name string, publicState ReadableState) (*ChaincodeDefinition, error)

	// QueryOrgApprovals returns a map containing the orgs whose orgStates were
	// supplied and whether or not they have approved a chaincode definition with
	// the specified parameters.
	QueryOrgApprovals(name string, cd *ChaincodeDefinition, orgStates []OpaqueState) (map[string]bool, error)

	// QueryNamespaceDefinitions returns all defined namespaces
	QueryNamespaceDefinitions(publicState RangeableState) (map[string]string, error)
}

SCCFunctions provides a backing implementation with concrete arguments for each of the SCC functions

type Serializer added in v1.5.6

type Serializer struct {
	// Marshaler, when nil uses the standard protobuf impl.
	// Can be overridden for test.
	Marshaler Marshaler
}

Serializer is used to write structures into the db and to read them back out. Although it's unfortunate to write a custom serializer, rather than to use something pre-written, like protobuf or JSON, in order to produce precise readwrite sets which only perform state updates for keys which are actually updated (and not simply set to the same value again) custom serialization is required.

func (*Serializer) Deserialize added in v1.5.6

func (s *Serializer) Deserialize(namespace, name string, metadata *lb.StateMetadata, structure interface{}, state ReadableState) error

Deserialize accepts a struct (of a type previously serialized) and populates it with the values from the db. Note: The struct names for the serialization and deserialization must match exactly. Unencoded fields are not populated, and the extraneous keys are ignored. The metadata provided should have been returned by a DeserializeMetadata call for the same namespace and name.

func (*Serializer) DeserializeAllMetadata added in v1.5.6

func (s *Serializer) DeserializeAllMetadata(namespace string, state RangeableState) (map[string]*lb.StateMetadata, error)

func (*Serializer) DeserializeField added in v1.5.6

func (s *Serializer) DeserializeField(namespace, name, field string, state ReadableState) (*lb.StateData, error)

func (*Serializer) DeserializeFieldAsBytes added in v1.5.6

func (s *Serializer) DeserializeFieldAsBytes(namespace, name, field string, state ReadableState) ([]byte, error)

func (*Serializer) DeserializeFieldAsInt64 added in v1.5.6

func (s *Serializer) DeserializeFieldAsInt64(namespace, name, field string, state ReadableState) (int64, error)

func (*Serializer) DeserializeFieldAsProto added in v1.5.6

func (s *Serializer) DeserializeFieldAsProto(namespace, name, field string, state ReadableState, msg proto.Message) error

func (*Serializer) DeserializeFieldAsString added in v1.5.6

func (s *Serializer) DeserializeFieldAsString(namespace, name, field string, state ReadableState) (string, error)

func (*Serializer) DeserializeMetadata added in v1.5.6

func (s *Serializer) DeserializeMetadata(namespace, name string, state ReadableState) (*lb.StateMetadata, bool, error)

func (*Serializer) IsMetadataSerialized added in v1.5.6

func (s *Serializer) IsMetadataSerialized(namespace, name string, structure interface{}, state OpaqueState) (bool, error)

func (*Serializer) IsSerialized added in v1.5.6

func (s *Serializer) IsSerialized(namespace, name string, structure interface{}, state OpaqueState) (bool, error)

IsSerialized essentially checks if the hashes of a serialized version of a structure matches the hashes of the pre-image of some struct serialized into the database.

func (*Serializer) SerializableChecks added in v1.5.6

func (s *Serializer) SerializableChecks(structure interface{}) (reflect.Value, []string, error)

SerializableChecks performs some boilerplate checks to make sure the given structure is serializable. It returns the reflected version of the value and a slice of all field names, or an error.

func (*Serializer) Serialize added in v1.5.6

func (s *Serializer) Serialize(namespace, name string, structure interface{}, state ReadWritableState) error

Serialize takes a pointer to a struct, and writes each of its fields as keys into a namespace. It also writes the struct metadata (if it needs updating) and, deletes any keys in the namespace which are not found in the struct. Note: If a key already exists for the field, and the value is unchanged, then the key is _not_ written to.

type SimpleQueryExecutorShim added in v1.5.6

type SimpleQueryExecutorShim struct {
	Namespace           string
	SimpleQueryExecutor ledger.SimpleQueryExecutor
}

SimpleQueryExecutorShim implements the ReadableState and RangeableState interfaces based on an underlying ledger.SimpleQueryExecutor

func (*SimpleQueryExecutorShim) GetState added in v1.5.6

func (sqes *SimpleQueryExecutorShim) GetState(key string) ([]byte, error)

func (*SimpleQueryExecutorShim) GetStateRange added in v1.5.6

func (sqes *SimpleQueryExecutorShim) GetStateRange(prefix string) (map[string][]byte, error)

type StateIterator added in v1.5.6

type StateIterator interface {
	Close() error
	Next() (*queryresult.KV, error)
}

type ValidatorCommitter added in v1.5.6

type ValidatorCommitter struct {
	CoreConfig                   *peer.Config
	PrivdataConfig               *privdata.PrivdataConfig
	Resources                    *Resources
	LegacyDeployedCCInfoProvider LegacyDeployedCCInfoProvider
}

func (*ValidatorCommitter) AllChaincodesInfo added in v1.5.6

func (vc *ValidatorCommitter) AllChaincodesInfo(channelName string, sqe ledger.SimpleQueryExecutor) (map[string]*ledger.DeployedChaincodeInfo, error)

AllChaincodesInfo returns the mapping of chaincode name to DeployedChaincodeInfo for all the deployed chaincodes

func (*ValidatorCommitter) AllCollectionsConfigPkg added in v1.5.6

func (vc *ValidatorCommitter) AllCollectionsConfigPkg(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) (*pb.CollectionConfigPackage, error)

AllCollectionsConfigPkg implements function in interface ledger.DeployedChaincodeInfoProvider this implementation returns a combined collection config pkg that contains both explicit and implicit collections

func (*ValidatorCommitter) ChaincodeImplicitCollections added in v1.5.6

func (vc *ValidatorCommitter) ChaincodeImplicitCollections(channelName string) ([]*pb.StaticCollectionConfig, error)

ChaincodeImplicitCollections assumes the chaincode exists in the new lifecycle and returns the implicit collections

func (*ValidatorCommitter) ChaincodeInfo added in v1.5.6

func (vc *ValidatorCommitter) ChaincodeInfo(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) (*ledger.DeployedChaincodeInfo, error)

func (*ValidatorCommitter) CollectionInfo added in v1.5.6

func (vc *ValidatorCommitter) CollectionInfo(channelName, chaincodeName, collectionName string, qe ledger.SimpleQueryExecutor) (*pb.StaticCollectionConfig, error)

CollectionInfo implements function in interface ledger.DeployedChaincodeInfoProvider, it returns config for both static and implicit collections.

func (*ValidatorCommitter) CollectionValidationInfo added in v1.5.6

func (vc *ValidatorCommitter) CollectionValidationInfo(channelID, chaincodeName, collectionName string, state validationState.State) (args []byte, unexpectedErr, validationErr error)

CollectionValidationInfo returns information about collections to the validation component

func (*ValidatorCommitter) GenerateImplicitCollectionForOrg added in v1.5.6

func (vc *ValidatorCommitter) GenerateImplicitCollectionForOrg(mspid string) *pb.StaticCollectionConfig

GenerateImplicitCollectionForOrg generates implicit collection for the org

func (*ValidatorCommitter) ImplicitCollectionEndorsementPolicyAsBytes added in v1.5.6

func (vc *ValidatorCommitter) ImplicitCollectionEndorsementPolicyAsBytes(channelID, orgMSPID string) (policy []byte, unexpectedErr, validationErr error)

func (*ValidatorCommitter) ImplicitCollections added in v1.5.6

func (vc *ValidatorCommitter) ImplicitCollections(channelName, chaincodeName string, qe ledger.SimpleQueryExecutor) ([]*pb.StaticCollectionConfig, error)

ImplicitCollections implements function in interface ledger.DeployedChaincodeInfoProvider. It returns a slice that contains one proto msg for each of the implicit collections

func (*ValidatorCommitter) Namespaces added in v1.5.6

func (vc *ValidatorCommitter) Namespaces() []string

Namespaces returns the list of namespaces which are relevant to chaincode lifecycle

func (*ValidatorCommitter) UpdatedChaincodes added in v1.5.6

func (vc *ValidatorCommitter) UpdatedChaincodes(stateUpdates map[string][]*kvrwset.KVWrite) ([]*ledger.ChaincodeLifecycleInfo, error)

UpdatedChaincodes returns the chaincodes that are getting updated by the supplied 'stateUpdates'

func (*ValidatorCommitter) ValidationInfo added in v1.5.6

func (vc *ValidatorCommitter) ValidationInfo(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (plugin string, args []byte, unexpectedErr error, validationErr error)

ValidationInfo returns the name and arguments of the validation plugin for the supplied chaincode. The function returns two types of errors, unexpected errors and validation errors. The reason for this is that this function is called from the validation code, which needs to differentiate the two types of error to halt processing on the channel if the unexpected error is not nil and mark the transaction as invalid if the validation error is not nil.

type ValidatorStateShim added in v1.5.6

type ValidatorStateShim struct {
	ValidatorState validatorstate.State
	Namespace      string
}

func (*ValidatorStateShim) GetState added in v1.5.6

func (vss *ValidatorStateShim) GetState(key string) ([]byte, error)

type VersionedValue added in v1.5.6

type VersionedValue struct {
	Txid string
	Val  []byte
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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