Documentation
¶
Index ¶
- Constants
- Variables
- type Block
- type BlockCallback
- type BlockNum
- type Chaincode
- type ChaincodeConfig
- type ChaincodeDiscover
- type ChaincodeInvocation
- type ChaincodeManager
- type Channel
- type ChannelConfig
- type ChannelConfigProvider
- type ChannelMembership
- type Committer
- type ConfigService
- type Configuration
- type Delivery
- type DeliveryCallback
- type DiscoveredPeer
- type Driver
- type EndorseTxStore
- type EndorserTransactionService
- type Envelope
- type EnvelopeService
- type EnvelopeStore
- type FabricNetworkService
- type FabricNetworkServiceProvider
- type Finality
- type FinalityListener
- type GetIdentityFunc
- type GetStateOpt
- type IdentityInfo
- type IdentityOptions
- type IdentityProvider
- type Key
- type Ledger
- type LedgerInfo
- type ListenerManager
- type ListenerManagerProvider
- type LocalMembership
- type MSP
- type MSPIdentity
- type MSPManager
- type MembershipService
- type MetadataService
- type MetadataStore
- type Ordering
- type PeerFunctionType
- type ProcessTransaction
- type ProcessedTransaction
- type Processor
- type ProcessorManager
- type Proposal
- type ProposalResponse
- type QueryExecutor
- type RWSExtractor
- type RWSet
- type RWSetInspector
- type RWSetLoader
- type RWSetPayloadHandler
- type RWSetPayloadHandlerProvider
- type Request
- type Resolver
- type SignedProposal
- type Signer
- type SignerService
- type SigningIdentity
- type Transaction
- type TransactionFactory
- type TransactionFilter
- type TransactionManager
- type TransactionStatusChanged
- type TransactionType
- type TransientMap
- type TxID
- type TxIDComponents
- type TxNum
- type TxStatus
- type TxValidationStatus
- type ValidationCode
- type Vault
- type VaultStore
- type Verifier
- type VerifierProvider
Constants ¶
const ( // PeerForAnything defines the class of peers that can be used for any function PeerForAnything = iota // PeerForDelivery defines the class of peers to be used for delivery PeerForDelivery // PeerForDiscovery defines the class of peers to be used for discovery PeerForDiscovery // PeerForFinality defines the class of peers to be used for finality PeerForFinality // PeerForQuery defines the class of peers to be used for query PeerForQuery )
const (
EndorserTransaction = TransactionType(common.HeaderType_ENDORSER_TRANSACTION)
)
Variables ¶
var ValidationCodeProvider = driver.NewValidationCodeProvider(map[ValidationCode]driver.TxStatusCode{ Valid: driver.Valid, Invalid: driver.Invalid, Busy: driver.Busy, Unknown: driver.Unknown, })
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block interface {
// DataAt returns the data stored at the passed index
DataAt(i int) []byte
// ProcessedTransaction returns the ProcessedTransaction at passed index
ProcessedTransaction(i int) (ProcessedTransaction, error)
}
Block models a block of the ledger
type BlockCallback ¶ added in v0.4.0
BlockCallback is the callback function prototype to alert the rest of the stack about the availability of a new block. The function returns two argument a boolean to signal if delivery should be stopped, and an error to signal an issue during the processing of the block. In case of an error, the same block is re-processed after a delay.
type Chaincode ¶
type Chaincode interface {
NewInvocation(function string, args ...interface{}) ChaincodeInvocation
NewDiscover() ChaincodeDiscover
IsAvailable() (bool, error)
IsPrivate() bool
// Version returns the version of this chaincode.
// It returns an error if a failure happens during the computation.
Version() (string, error)
}
Chaincode exposes chaincode-related functions
type ChaincodeConfig ¶ added in v0.4.0
type ChaincodeDiscover ¶
type ChaincodeDiscover interface {
// Call invokes discovery service and returns the discovered peers
Call() ([]DiscoveredPeer, error)
WithFilterByMSPIDs(mspIDs ...string) ChaincodeDiscover
WithImplicitCollections(mspIDs ...string) ChaincodeDiscover
}
ChaincodeDiscover models a client-side chaincode's endorsers discovery operation
type ChaincodeInvocation ¶
type ChaincodeInvocation interface {
Endorse() (Envelope, error)
Query() ([]byte, error)
Submit() (string, []byte, error)
WithTransientEntry(k string, v interface{}) (ChaincodeInvocation, error)
WithEndorsersByMSPIDs(mspIDs ...string) ChaincodeInvocation
WithEndorsersFromMyOrg() ChaincodeInvocation
WithSignerIdentity(id view.Identity) ChaincodeInvocation
WithTxID(id TxIDComponents) ChaincodeInvocation
WithEndorsersByConnConfig(ccs ...*grpc.ConnectionConfig) ChaincodeInvocation
WithImplicitCollections(mspIDs ...string) 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.
WithDiscoveredEndorsersByEndpoints(endpoints ...string) ChaincodeInvocation
// WithMatchEndorsementPolicy enforces that the query is perfomed against a set of peers that satisfy the
// endorsement policy of the chaincode
WithMatchEndorsementPolicy() ChaincodeInvocation
// WithNumRetries sets the number of times the chaincode operation should be retried before returning a failure
WithNumRetries(numRetries uint) ChaincodeInvocation
// WithRetrySleep sets the time interval between each retry
WithRetrySleep(duration time.Duration) ChaincodeInvocation
WithContext(context context.Context) ChaincodeInvocation
}
ChaincodeInvocation models a client-side chaincode invocation
type ChaincodeManager ¶
type ChaincodeManager interface {
// Chaincode returns a chaincode handler for the passed chaincode name
Chaincode(name string) Chaincode
}
ChaincodeManager manages chaincodes
type Channel ¶
type Channel interface {
// Name returns the name of the channel this instance is bound to
Name() string
Committer() Committer
Vault() Vault
VaultStore() VaultStore
Delivery() Delivery
Ledger() Ledger
Finality() Finality
ChannelMembership() ChannelMembership
ChaincodeManager() ChaincodeManager
RWSetLoader() RWSetLoader
EnvelopeService() EnvelopeService
TransactionService() EndorserTransactionService
MetadataService() MetadataService
Close() error
}
Channel gives access to Fabric channel related information
type ChannelConfig ¶ added in v0.4.0
type ChannelConfig interface {
ID() string
FinalityWaitTimeout() time.Duration
FinalityForPartiesWaitTimeout() time.Duration
FinalityEventQueueWorkers() int
CommitterPollingTimeout() time.Duration
CommitterFinalityNumRetries() int
CommitterFinalityUnknownTXTimeout() time.Duration
CommitterWaitForEventTimeout() time.Duration
DeliveryBufferSize() int
DeliverySleepAfterFailure() time.Duration
CommitParallelism() int
ChaincodeConfigs() []ChaincodeConfig
GetNumRetries() uint
GetRetrySleep() time.Duration
DiscoveryDefaultTTLS() time.Duration
DiscoveryTimeout() time.Duration
}
type ChannelConfigProvider ¶ added in v0.4.0
type ChannelConfigProvider interface {
GetChannelConfig(network, channel string) (ChannelConfig, error)
}
type ChannelMembership ¶
type Committer ¶
type Committer interface {
Start(context context.Context) error
// ProcessNamespace registers namespaces that will be committed even if the rwset is not known
ProcessNamespace(nss ...driver.Namespace) error
// AddTransactionFilter adds a new transaction filter to this commit pipeline.
// The transaction filter is used to check if an unknown transaction needs to be processed anyway
AddTransactionFilter(tf TransactionFilter) error
// Status returns a validation code this committer bind to the passed transaction id, plus
// a list of dependant transaction ids if they exist.
Status(context context.Context, txID driver.TxID) (ValidationCode, string, error)
// AddFinalityListener registers a listener for transaction status for the passed transaction id.
// If the status is already valid or invalid, the listener is called immediately.
// When the listener is invoked, then it is also removed.
// The transaction id must not be empty.
AddFinalityListener(txID string, listener FinalityListener) error
// RemoveFinalityListener unregisters the passed listener.
RemoveFinalityListener(txID string, listener FinalityListener) error
DiscardTx(context context.Context, txID driver.TxID, message string) error
CommitTX(ctx context.Context, txID driver.TxID, block driver.BlockNum, indexInBlock driver.TxNum, envelope *common.Envelope) error
}
Committer models the committer service
type ConfigService ¶
type ConfigService interface {
Configuration
NetworkName() string
DriverName() string
DefaultChannel() string
Channel(name string) ChannelConfig
ChannelIDs() []string
Orderers() []*grpc.ConnectionConfig
// OrderingTLSEnabled returns true, true if TLS is enabled because the key was set.
// Default value is true.
OrderingTLSEnabled() (bool, bool)
// OrderingTLSClientAuthRequired returns true, true if TLS client-side authentication is enabled because the key was set.
// Default value is false
OrderingTLSClientAuthRequired() (bool, bool)
SetConfigOrderers([]*grpc.ConnectionConfig) error
PickOrderer() *grpc.ConnectionConfig
BroadcastNumRetries() int
BroadcastRetryInterval() time.Duration
OrdererConnectionPoolSize() int
PickPeer(funcType PeerFunctionType) *grpc.ConnectionConfig
IsChannelQuiet(name string) bool
VaultPersistenceName() driver2.PersistenceName
VaultTXStoreCacheSize() int
TLSServerHostOverride() string
ClientConnTimeout() time.Duration
TLSClientAuthRequired() bool
TLSClientKeyFile() string
TLSClientCertFile() string
KeepAliveClientInterval() time.Duration
KeepAliveClientTimeout() time.Duration
NewDefaultChannelConfig(name string) ChannelConfig
TLSEnabled() bool
}
type Configuration ¶ added in v0.4.0
type Configuration interface {
// GetString returns the value associated with the key as a string
GetString(key string) string
// GetInt returns the value associated with the key as an integer
GetInt(key string) int
// GetDuration returns the value associated with the key as a duration
GetDuration(key string) time.Duration
// GetBool returns the value associated with the key asa boolean
GetBool(key string) bool
// GetStringSlice returns the value associated with the key as a slice of strings
GetStringSlice(key string) []string
// IsSet checks to see if the key has been set in any of the data locations
IsSet(key string) bool
// UnmarshalKey takes a single key and unmarshals it into a Struct
UnmarshalKey(key string, rawVal interface{}) error
// ConfigFileUsed returns the file used to populate the config registry
ConfigFileUsed() string
// GetPath allows configuration strings that specify a (config-file) relative path
GetPath(key string) string
// TranslatePath translates the passed path relative to the config path
TranslatePath(path string) string
}
type Delivery ¶
type Delivery interface {
// Start starts the delivery process
Start(ctx context.Context) error
// ScanBlock iterates over all blocks.
// On each block, the callback function is invoked.
ScanBlock(ctx context.Context, callback BlockCallback) error
// ScanBlockFrom iterates over all blocks starting from the block with the passed number.
// On each block, the callback function is invoked.
ScanBlockFrom(ctx context.Context, block BlockNum, callback BlockCallback) error
// Scan iterates over all transactions in block starting from the block containing the passed transaction id.
// If txID is empty, the iterations starts from the first block.
// On each transaction, the callback function is invoked.
Scan(ctx context.Context, txID TxID, callback DeliveryCallback) error
// ScanFromBlock iterates over all transactions in block starting from the block with the passed number.
// On each transaction, the callback function is invoked.
ScanFromBlock(ctx context.Context, block BlockNum, callback DeliveryCallback) error
}
Delivery gives access to Fabric channel delivery
type DeliveryCallback ¶
type DeliveryCallback func(tx ProcessedTransaction) (bool, error)
DeliveryCallback is a callback function used to process a transaction. Return true, if the scan should finish.
type DiscoveredPeer ¶
type DiscoveredPeer struct {
// Identity is the identity of the peer (MSP Identity)
Identity view.Identity
// MSPID is the MSP ID of the peer
MSPID string
// Endpoint is the endpoint of the peer
Endpoint string
// TLSRootCerts is the TLS root certs of the peer
TLSRootCerts [][]byte
}
DiscoveredPeer contains the information of a discovered peer
type Driver ¶ added in v0.2.0
type Driver interface {
// New returns a new network instance for the passed network and channel (if applicable)
New(network string, defaultNetwork bool) (FabricNetworkService, error)
}
Driver models the network driver factory
type EndorseTxStore ¶ added in v0.4.1
type EndorseTxStore interface {
driver.EndorseTxStore[Key]
}
type EnvelopeService ¶
type EnvelopeStore ¶ added in v0.4.1
type EnvelopeStore interface {
driver.EnvelopeStore[Key]
}
type FabricNetworkService ¶
type FabricNetworkService interface {
Name() string
OrderingService() Ordering
TransactionManager() TransactionManager
ProcessorManager() ProcessorManager
LocalMembership() LocalMembership
IdentityProvider() IdentityProvider
// Channel returns the channel whose name is the passed one.
// If the empty string is passed, the default channel is returned, if defined.
Channel(name string) (Channel, error)
// Ledger returns the ledger for the channel whose name is the passed one.
Ledger(name string) (Ledger, error)
// Committer returns the committer for the channel whose name is the passed one.
Committer(name string) (Committer, error)
SignerService() SignerService
ConfigService() ConfigService
}
FabricNetworkService gives access to a Fabric network components
type FabricNetworkServiceProvider ¶
type FabricNetworkServiceProvider interface {
Names() []string
DefaultName() string
// FabricNetworkService returns a FabricNetworkService instance for the passed parameters
FabricNetworkService(id string) (FabricNetworkService, error)
}
func GetFabricManagementService ¶
func GetFabricManagementService(ctx services.Provider) FabricNetworkServiceProvider
type FinalityListener ¶ added in v0.4.0
type FinalityListener = driver.FinalityListener[ValidationCode]
FinalityListener is the interface that must be implemented to receive transaction status notifications
type GetIdentityFunc ¶
type GetIdentityFunc func(opts *IdentityOptions) (view.Identity, []byte, error)
type GetStateOpt ¶
type GetStateOpt = driver.GetStateOpt
type IdentityInfo ¶
type IdentityInfo struct {
ID string
EnrollmentID string
GetIdentity GetIdentityFunc
}
type IdentityOptions ¶
type IdentityProvider ¶
type IdentityProvider interface {
// Identity returns the Fabric identity bound to the passed label.
// If not Fabric identity is associated to the label, it returns the SFC identity bound to that label.
Identity(label string) (view.Identity, error)
}
IdentityProvider models the identity provider
type Ledger ¶
type Ledger interface {
// GetLedgerInfo returns the ledger info
GetLedgerInfo() (*LedgerInfo, error)
// GetTransactionByID retrieves a transaction by id
GetTransactionByID(txID string) (ProcessedTransaction, error)
// GetBlockNumberByTxID returns the number of the block where the passed transaction appears
GetBlockNumberByTxID(txID string) (uint64, error)
// GetBlockByNumber fetches a block by number
GetBlockByNumber(number uint64) (Block, error)
}
Ledger gives access to the remote ledger
type LedgerInfo ¶ added in v0.4.1
type ListenerManager ¶ added in v0.4.0
type ListenerManager driver.ListenerManager[ValidationCode]
type ListenerManagerProvider ¶ added in v0.4.0
type ListenerManagerProvider driver.ListenerManagerProvider[ValidationCode]
type LocalMembership ¶
type LocalMembership interface {
DefaultIdentity() view.Identity
AnonymousIdentity() (view.Identity, error)
IsMe(ctx context.Context, id view.Identity) bool
DefaultSigningIdentity() SigningIdentity
RegisterX509MSP(id string, path string, mspID string) error
RegisterIdemixMSP(id string, path string, mspID string) error
GetIdentityByID(id string) (view.Identity, error)
GetIdentityInfoByLabel(mspType string, label string) *IdentityInfo
GetIdentityInfoByIdentity(mspType string, id view.Identity) *IdentityInfo
Refresh() error
}
type MSPIdentity ¶
type MSPManager ¶
type MSPManager interface {
DeserializeIdentity(serializedIdentity []byte) (MSPIdentity, error)
}
type MembershipService ¶ added in v0.5.0
type MembershipService interface {
ChannelMembership
Update(env *common.Envelope) error
DryUpdate(env *common.Envelope) error
OrdererConfig(cs ConfigService) (string, []*grpc.ConnectionConfig, error)
}
type MetadataService ¶
type MetadataStore ¶ added in v0.4.1
type MetadataStore interface {
driver.MetadataStore[Key, TransientMap]
}
type Ordering ¶
type Ordering interface {
// Broadcast sends the passed blob to the ordering service to be ordered
Broadcast(context context.Context, blob interface{}) error
// SetConsensusType sets the consensus type the ordering service should use
SetConsensusType(consensusType string) error
}
Ordering models the ordering service
type PeerFunctionType ¶ added in v0.3.0
type PeerFunctionType int
PeerFunctionType defines classes of peers providing a specific functionality
type ProcessTransaction ¶
type ProcessedTransaction ¶
type ProcessedTransaction interface {
// TxID returns the transaction's id
TxID() string
// Results returns the rwset marshaled
Results() []byte
// ValidationCode of this transaction
ValidationCode() int32
// IsValid returns true if the transaction is valid, false otherwise
IsValid() bool
// Envelope returns the Fabric envelope
Envelope() []byte
}
ProcessedTransaction models a transaction that has been processed by Fabric
type Processor ¶
type Processor interface {
Process(req Request, tx ProcessTransaction, rws RWSet, ns string) error
}
type ProcessorManager ¶
type ProposalResponse ¶
type QueryExecutor ¶
type QueryExecutor = driver.QueryExecutor
type RWSExtractor ¶
type RWSExtractor interface {
Extract(tx []byte) (ProcessTransaction, RWSet, error)
}
type RWSetInspector ¶ added in v0.4.0
type RWSetLoader ¶
type RWSetLoader interface {
AddHandlerProvider(headerType common.HeaderType, handlerProvider RWSetPayloadHandlerProvider) error
GetRWSetFromEvn(ctx context.Context, txID driver.TxID) (RWSet, ProcessTransaction, error)
GetRWSetFromETx(ctx context.Context, txID driver.TxID) (RWSet, ProcessTransaction, error)
GetInspectingRWSetFromEvn(ctx context.Context, id driver.TxID, envelopeRaw []byte) (RWSet, ProcessTransaction, error)
}
type RWSetPayloadHandler ¶ added in v0.4.0
type RWSetPayloadHandler interface {
Load(payl *common.Payload, header *common.ChannelHeader) (RWSet, ProcessTransaction, error)
}
type RWSetPayloadHandlerProvider ¶ added in v0.4.0
type RWSetPayloadHandlerProvider = func(network, channel string, v RWSetInspector) RWSetPayloadHandler
type SignedProposal ¶
type SigningIdentity ¶
type Transaction ¶
type Transaction interface {
Creator() view.Identity
Nonce() []byte
ID() string
Network() string
Channel() string
Function() string
Parameters() [][]byte
FunctionAndParameters() (string, []string)
Chaincode() string
ChaincodeVersion() string
Results() ([]byte, error)
From(payload Transaction) (err error)
SetFromBytes(raw []byte) error
SetFromEnvelopeBytes(raw []byte) error
Proposal() Proposal
SignedProposal() SignedProposal
SetProposal(chaincode string, version string, function string, params ...string)
AppendParameter(p []byte)
SetParameterAt(i int, p []byte) error
Transient() TransientMap
ResetTransient()
SetRWSet() error
RWS() RWSet
Done() error
Close()
Raw() ([]byte, error)
GetRWSet() (RWSet, error)
Bytes() ([]byte, error)
Endorse() error
EndorseWithIdentity(identity view.Identity) error
EndorseWithSigner(identity view.Identity, s Signer) error
EndorseProposal() error
EndorseProposalWithIdentity(identity view.Identity) error
EndorseProposalResponse() error
EndorseProposalResponseWithIdentity(identity view.Identity) error
AppendProposalResponse(response ProposalResponse) error
ProposalHasBeenEndorsedBy(party view.Identity) error
StoreTransient() error
ProposalResponses() ([]ProposalResponse, error)
ProposalResponse() ([]byte, error)
BytesNoTransient() ([]byte, error)
Envelope() (Envelope, error)
}
type TransactionFactory ¶ added in v0.4.0
type TransactionFilter ¶ added in v0.4.0
type TransactionFilter = driver.TransactionFilter
TransactionFilter is used to filter unknown transactions. If the filter accepts, the transaction is processed by the commit pipeline anyway.
type TransactionManager ¶
type TransactionManager interface {
ComputeTxID(id *TxIDComponents) string
NewEnvelope() Envelope
NewProposalResponseFromBytes(raw []byte) (ProposalResponse, error)
NewTransaction(ctx context.Context, transactionType TransactionType, creator view.Identity, nonce []byte, txid string, channel string, rawRequest []byte) (Transaction, error)
NewTransactionFromBytes(ctx context.Context, channel string, raw []byte) (Transaction, error)
NewTransactionFromEnvelopeBytes(ctx context.Context, channel string, raw []byte) (Transaction, error)
AddTransactionFactory(tt TransactionType, factory TransactionFactory)
NewProcessedTransactionFromEnvelopePayload(envelopePayload []byte) (ProcessedTransaction, int32, error)
NewProcessedTransactionFromEnvelopeRaw(envelope []byte) (ProcessedTransaction, error)
NewProcessedTransaction(pt []byte) (ProcessedTransaction, error)
}
type TransactionStatusChanged ¶
type TransactionStatusChanged struct {
ThisTopic string
TxID string
VC ValidationCode
ValidationMessage string
}
TransactionStatusChanged is sent when the status of a transaction changes
func (*TransactionStatusChanged) Message ¶
func (t *TransactionStatusChanged) Message() interface{}
Message returns the message for the transaction status change
func (*TransactionStatusChanged) Topic ¶
func (t *TransactionStatusChanged) Topic() string
Topic returns the topic for the transaction status change
type TransactionType ¶ added in v0.4.0
type TransactionType int32
type TransientMap ¶
type TxIDComponents ¶ added in v0.4.1
type TxValidationStatus ¶ added in v0.4.0
type TxValidationStatus = driver.TxValidationStatus[ValidationCode]
type ValidationCode ¶
type ValidationCode = int
ValidationCode of transaction
const ( Valid ValidationCode // Transaction is valid and committed Invalid // Transaction is invalid and has been discarded Busy // Transaction does not yet have a validity state Unknown // Transaction is unknown )
type Vault ¶
type Vault interface {
driver.Vault[ValidationCode]
// InspectRWSet returns an ephemeral RWSet for this ledger whose content is unmarshalled
// from the passed bytes.
// If namespaces is not empty, the returned RWSet will be filtered by the passed namespaces
InspectRWSet(ctx context.Context, rwset []byte, namespaces ...driver.Namespace) (RWSet, error)
RWSExists(ctx context.Context, id driver.TxID) bool
Match(ctx context.Context, id driver.TxID, results []byte) error
Close() error
}
type VaultStore ¶ added in v0.4.1
type VaultStore interface {
GetState(ctx context.Context, namespace driver.Namespace, key driver.PKey) (*driver.VaultRead, error)
GetStateRange(ctx context.Context, namespace driver.Namespace, startKey, endKey driver.PKey) (driver.TxStateIterator, error)
GetLast(ctx context.Context) (*TxStatus, error)
}