chaincode

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscoveryCacheTimeout = time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster added in v0.4.0

type Broadcaster interface {
	Broadcast(ctx context.Context, blob any) error
}

type Chaincode

type Chaincode struct {
	NetworkID       string
	ChannelID       string
	ConfigService   driver.ConfigService
	ChannelConfig   driver.ChannelConfig
	NumRetries      uint
	RetrySleep      time.Duration
	LocalMembership driver.LocalMembership
	Services        Services
	SignerService   driver.SignerService
	Broadcaster     Broadcaster
	Finality        driver.Finality
	MSPProvider     MSPProvider
	// contains filtered or unexported fields
}

func NewChaincode

func NewChaincode(
	ctx context.Context,
	name string,
	networkConfig driver.ConfigService,
	channelConfig driver.ChannelConfig,
	localMembership driver.LocalMembership,
	peerManager Services,
	signerService driver.SignerService,
	broadcaster Broadcaster,
	finality driver.Finality,
	MSPProvider MSPProvider,
) *Chaincode

NewChaincode creates a Chaincode handler. networkConfig and channelConfig are required and must not be nil.

Discovery results are cached for the lifetime of the returned Chaincode. The TTL of the cached results can be set via the `ChannelConfig.DiscoveryTimeout()` of the channelConfig parameter. If not set, the default `DiscoveryCacheTimeout` is used. The cache's background eviction goroutine is stopped when ctx is cancelled.

func (*Chaincode) IsAvailable

func (c *Chaincode) IsAvailable() (bool, error)

func (*Chaincode) NewDiscover

func (c *Chaincode) NewDiscover() driver.ChaincodeDiscover

func (*Chaincode) NewInvocation

func (c *Chaincode) NewInvocation(function string, args ...any) driver.ChaincodeInvocation

func (*Chaincode) Version

func (c *Chaincode) Version() (string, error)

Version returns the version of this chaincode. It uses discovery to extract this information from the endorsers

type Discovery

type Discovery struct {
	FilterByMSPIDs      []string
	ImplicitCollections []string
	QueryForPeers       bool
	// contains filtered or unexported fields
}

func NewDiscovery

func NewDiscovery(chaincode *Chaincode) *Discovery

NewDiscovery create a discovery client that helps to fetch peer information.

Discovery results are cached in a cache owned by chaincode (created once in NewChaincode) and shared across every Discovery instance created for that chaincode, so its lifetime (and background eviction goroutine) is bound to the chaincode rather than to this single Discovery instance.

func (*Discovery) Call

func (d *Discovery) Call() ([]driver.DiscoveredPeer, error)

func (*Discovery) ChaincodeVersion

func (d *Discovery) ChaincodeVersion() (string, error)

func (*Discovery) GetEndorsers

func (d *Discovery) GetEndorsers() ([]driver.DiscoveredPeer, error)

func (*Discovery) GetPeers

func (d *Discovery) GetPeers() ([]driver.DiscoveredPeer, error)

func (*Discovery) Response

func (d *Discovery) Response() (discovery.Response, error)

func (*Discovery) WithFilterByMSPIDs

func (d *Discovery) WithFilterByMSPIDs(mspIDs ...string) driver.ChaincodeDiscover

func (*Discovery) WithForQuery

func (d *Discovery) WithForQuery() driver.ChaincodeDiscover

func (*Discovery) WithImplicitCollections

func (d *Discovery) WithImplicitCollections(mspIDs ...string) driver.ChaincodeDiscover

type Invoke

type Invoke struct {
	Chaincode                      *Chaincode
	TxID                           driver.TxIDComponents
	SignerIdentity                 view.Identity
	ChaincodePath                  string
	ChaincodeName                  string
	ChaincodeVersion               string
	TransientMap                   map[string][]byte
	EndorsersMSPIDs                []string
	ImplicitCollectionMSPIDs       []string
	EndorsersFromMyOrg             bool
	EndorsersByConnConfig          []*grpc.ConnectionConfig
	DiscoveredEndorsersByEndpoints []string
	Function                       string
	Args                           []any
	MatchEndorsementPolicy         bool
	NumRetries                     int
	RetrySleep                     time.Duration
	Ctx                            context.Context
}

func NewInvoke

func NewInvoke(chaincode *Chaincode, function string, args ...any) *Invoke

func (*Invoke) Endorse

func (i *Invoke) Endorse() (driver.Envelope, error)

func (*Invoke) Query

func (i *Invoke) Query() ([]byte, error)

func (*Invoke) Submit

func (i *Invoke) Submit() (string, []byte, error)

func (*Invoke) WithContext added in v0.3.0

func (i *Invoke) WithContext(ctx context.Context) driver.ChaincodeInvocation

func (*Invoke) WithDiscoveredEndorsersByEndpoints

func (i *Invoke) WithDiscoveredEndorsersByEndpoints(endpoints ...string) driver.ChaincodeInvocation

WithDiscoveredEndorsersByEndpoints sets the endpoints to be used to filter the result of discovery. Discovery is used to identify the chaincode's endorsers, if not set otherwise.

func (*Invoke) WithEndorsersByConnConfig

func (i *Invoke) WithEndorsersByConnConfig(ccs ...*grpc.ConnectionConfig) driver.ChaincodeInvocation

func (*Invoke) WithEndorsersByMSPIDs

func (i *Invoke) WithEndorsersByMSPIDs(mspIDs ...string) driver.ChaincodeInvocation

func (*Invoke) WithEndorsersFromMyOrg

func (i *Invoke) WithEndorsersFromMyOrg() driver.ChaincodeInvocation

func (*Invoke) WithImplicitCollections

func (i *Invoke) WithImplicitCollections(mspIDs ...string) driver.ChaincodeInvocation

func (*Invoke) WithMatchEndorsementPolicy added in v0.2.0

func (i *Invoke) WithMatchEndorsementPolicy() driver.ChaincodeInvocation

func (*Invoke) WithNumRetries added in v0.2.0

func (i *Invoke) WithNumRetries(numRetries uint) driver.ChaincodeInvocation

func (*Invoke) WithRetrySleep added in v0.2.0

func (i *Invoke) WithRetrySleep(duration time.Duration) driver.ChaincodeInvocation

func (*Invoke) WithSignerIdentity

func (i *Invoke) WithSignerIdentity(id view.Identity) driver.ChaincodeInvocation

func (*Invoke) WithTransientEntry

func (i *Invoke) WithTransientEntry(k string, v any) (driver.ChaincodeInvocation, error)

func (*Invoke) WithTxID

type MSPProvider added in v0.4.0

type MSPProvider interface {
	MSPManager() driver.MSPManager
}

type Manager added in v0.4.0

type Manager struct {
	NetworkID       string
	ChannelID       string
	ConfigService   driver.ConfigService
	ChannelConfig   driver.ChannelConfig
	NumRetries      uint
	RetrySleep      time.Duration
	LocalMembership driver.LocalMembership
	PeerManager     Services
	SignerService   driver.SignerService
	Broadcaster     Broadcaster
	Finality        driver.Finality
	MSPProvider     MSPProvider

	// chaincodes
	ChaincodesLock sync.RWMutex
	Chaincodes     map[string]driver.Chaincode
	// contains filtered or unexported fields
}

func NewManager added in v0.4.0

func NewManager(
	ctx context.Context,
	networkID string,
	channelID string,
	configService driver.ConfigService,
	channelConfig driver.ChannelConfig,
	numRetries uint,
	retrySleep time.Duration,
	localMembership driver.LocalMembership,
	peerManager Services,
	signerService driver.SignerService,
	broadcaster Broadcaster,
	finality driver.Finality,
	MSPProvider MSPProvider,
) *Manager

func (*Manager) Chaincode added in v0.4.0

func (c *Manager) Chaincode(name string) driver.Chaincode

Chaincode returns a chaincode handler for the passed chaincode name

func (*Manager) Stop added in v0.18.0

func (c *Manager) Stop()

Stop cancels the Manager's context, stopping all per-chaincode discovery caches (and any other resource whose lifetime is bound to it).

type SerializableSigner

type SerializableSigner interface {
	Sign(message []byte) ([]byte, error)

	Serialize() ([]byte, error)
}

type Services added in v0.4.0

type Services interface {
	NewPeerClient(cc grpc.ConnectionConfig) (services.PeerClient, error)
}

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