Documentation
¶
Index ¶
- Constants
- type Block
- type ByNum
- type Chaincode
- type ChaincodeDiscover
- type ChaincodeInvocation
- type ChaincodeManager
- type Channel
- type ChannelMembership
- type Committer
- type Config
- type ConfigService
- type Delivery
- type DeliveryCallback
- type DiscoveredPeer
- type Driver
- type EndorserTransactionService
- type Envelope
- type EnvelopeService
- type FabricNetworkService
- type FabricNetworkServiceProvider
- type Finality
- type GetIdentityFunc
- type GetStateOpt
- type IdentityInfo
- type IdentityOptions
- type IdentityProvider
- type Ledger
- type LocalMembership
- type MSPIdentity
- type MSPManager
- type MetadataService
- type Ordering
- type PeerFunctionType
- type ProcessTransaction
- type ProcessedTransaction
- type Processor
- type ProcessorManager
- type Proposal
- type ProposalResponse
- type QueryExecutor
- type RWSExtractor
- type RWSet
- type RWSetLoader
- type Request
- type SeekEnd
- type SeekPos
- type SeekStart
- type SignedProposal
- type Signer
- type SignerService
- type SigningIdentity
- type TXIDStore
- type Transaction
- type TransactionManager
- type TransactionStatusChanged
- type TransientMap
- type TxID
- type TxStatusChangeListener
- type TxidIterator
- type ValidationCode
- type Vault
- type Verifier
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 )
Variables ¶
This section is empty.
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 ByNum ¶
type ByNum struct {
Txid string
Code ValidationCode
}
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 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
WithEndorsersByMSPIDs(mspIDs ...string) ChaincodeInvocation
WithEndorsersFromMyOrg() ChaincodeInvocation
WithSignerIdentity(id view.Identity) ChaincodeInvocation
WithTxID(id TxID) 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 {
Committer
Vault
Delivery
Ledger
Finality
ChannelMembership
TXIDStore
ChaincodeManager
RWSetLoader
// Name returns the name of the channel this instance is bound to
Name() string
EnvelopeService() EnvelopeService
TransactionService() EndorserTransactionService
MetadataService() MetadataService
// NewPeerClientForAddress creates an instance of a Client using the
// provided peer connection config
NewPeerClientForAddress(cc grpc.ConnectionConfig) (peer.Client, error)
Close() error
}
Channel gives access to Fabric channel related information
type ChannelMembership ¶
type Committer ¶
type Committer interface {
// ProcessNamespace registers namespaces that will be committed even if the rwset is not known
ProcessNamespace(nss ...string) 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(txid string) (ValidationCode, []string, error)
// DiscardTx discards the transaction with the passed id and all its dependencies, if they exists.
DiscardTx(txid string) error
// CommitTX commits the transaction with the passed id and all its dependencies, if they exists.
// Depending on tx's status, CommitTX does the following:
// Tx is Unknown, CommitTx does nothing and returns no error.
// Tx is HasDependencies, CommitTx proceeds with the multi-shard private transaction commit protocol.
// Tx is Valid, CommitTx does nothing and returns an error.
// Tx is Invalid, CommitTx does nothing and returns an error.
// Tx is Busy, if Tx is a multi-shard private transaction then CommitTx proceeds with the multi-shard private transaction commit protocol,
// otherwise, CommitTx commits the transaction.
CommitTX(txid string, block uint64, indexInBloc int, envelope *common.Envelope) error
// CommitConfig commits the passed configuration envelope.
CommitConfig(blockNumber uint64, raw []byte, envelope *common.Envelope) error
// SubscribeTxStatusChanges registers a listener for transaction status changes for the passed transaction id.
// If the transaction id is empty, the listener will be called for all transactions.
SubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) error
// UnsubscribeTxStatusChanges unregisters a listener for transaction status changes for the passed transaction id.
// If the transaction id is empty, the listener will be called for all transactions.
UnsubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) error
}
Committer models the committer service
type Config ¶
type Config interface {
// DefaultChannel returns the name of the default channel
DefaultChannel() string
// Channels return the list of registered channel names
Channels() []string
// Orderers returns the list of all registered ordereres
Orderers() []*grpc.ConnectionConfig
// Peers returns the list of all registered peers
Peers() []*grpc.ConnectionConfig
// PickPeer picks a peer at random among the peers that provide the passed functionality
PickPeer(funcType PeerFunctionType) *grpc.ConnectionConfig
}
Config defines basic information the configuration should provide
type ConfigService ¶
type ConfigService interface {
// GetString returns the value associated with the key as a string
GetString(key string) string
// 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
// 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
// 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 {
// StartDelivery starts the delivery process
StartDelivery(ctx context.Context) 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 string, 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(sp view.ServiceProvider, network string, defaultNetwork bool) (FabricNetworkService, error)
}
Driver models the network driver factory
type EnvelopeService ¶
type FabricNetworkService ¶
type FabricNetworkService interface {
Config
Ordering
Name() string
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 view2.ServiceProvider) FabricNetworkServiceProvider
type Finality ¶
type Finality interface {
// IsFinal takes in input a transaction id and waits for its confirmation
// with the respect to the passed context that can be used to set a deadline
// for the waiting time.
IsFinal(ctx context.Context, txID string) error
// IsFinalForParties takes in input a transaction id and an array of identities.
// The identities are contacted to gather information about the finality of the
// passed transaction
IsFinalForParties(txID string, parties ...view.Identity) error
}
type GetIdentityFunc ¶
type GetIdentityFunc func(opts *IdentityOptions) (view.Identity, []byte, error)
type GetStateOpt ¶
type GetStateOpt int
const ( FromStorage GetStateOpt = iota FromIntermediate FromBoth )
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 the SFC identity bound to that label.
Identity(label string) view.Identity
}
IdentityProvider models the identity provider
type Ledger ¶
type Ledger interface {
// 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 LocalMembership ¶
type LocalMembership interface {
DefaultIdentity() view.Identity
AnonymousIdentity() view.Identity
IsMe(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 MetadataService ¶
type MetadataService interface {
Exists(txid string) bool
StoreTransient(txid string, transientMap TransientMap) error
LoadTransient(txid string) (TransientMap, error)
}
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 RWSExtractor ¶
type RWSExtractor interface {
Extract(tx []byte) (ProcessTransaction, RWSet, error)
}
type RWSet ¶
type RWSet interface {
IsValid() error
Clear(ns string) error
// SetState sets the given value for the given namespace and key.
SetState(namespace string, key string, value []byte) error
GetState(namespace string, key string, opts ...GetStateOpt) ([]byte, error)
// DeleteState deletes the given namespace and key
DeleteState(namespace string, key string) error
GetStateMetadata(namespace, key string, opts ...GetStateOpt) (map[string][]byte, error)
// SetStateMetadata sets the metadata associated with an existing key-tuple <namespace, key>
SetStateMetadata(namespace, key string, metadata map[string][]byte) error
GetReadKeyAt(ns string, i int) (string, error)
// GetReadAt returns the i-th read (key, value) in the namespace ns of this rwset.
// The value is loaded from the ledger, if present. If the key's version in the ledger
// does not match the key's version in the read, then it returns an error.
GetReadAt(ns string, i int) (string, []byte, error)
// GetWriteAt returns the i-th write (key, value) in the namespace ns of this rwset.
GetWriteAt(ns string, i int) (string, []byte, error)
// NumReads returns the number of reads in the namespace ns of this rwset.
NumReads(ns string) int
// NumWrites returns the number of writes in the namespace ns of this rwset.
NumWrites(ns string) int
// Namespaces returns the namespace labels in this rwset.
Namespaces() []string
AppendRWSet(raw []byte, nss ...string) error
Bytes() ([]byte, error)
Done()
Equals(rws interface{}, nss ...string) error
}
type RWSetLoader ¶
type RWSetLoader interface {
GetRWSetFromEvn(txID string) (RWSet, ProcessTransaction, error)
GetRWSetFromETx(txID string) (RWSet, ProcessTransaction, error)
}
type SignedProposal ¶
type SignerService ¶
type SignerService interface {
// GetSigner returns the signer for the passed identity
GetSigner(id view.Identity) (Signer, error)
// GetSigningIdentity returns the signing identity for the passed identity
GetSigningIdentity(id view.Identity) (SigningIdentity, error)
// RegisterSigner register signer and verifier for the passed identity
RegisterSigner(identity view.Identity, signer Signer, verifier Verifier) error
}
SignerService models a signer service
type SigningIdentity ¶
type TXIDStore ¶
type TXIDStore interface {
GetLastTxID() (string, error)
Iterator(pos interface{}) (TxidIterator, error)
}
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
ProposalResponse() ([]byte, error)
BytesNoTransient() ([]byte, error)
Envelope() (Envelope, error)
}
type TransactionManager ¶
type TransactionManager interface {
ComputeTxID(id *TxID) string
NewEnvelope() Envelope
NewProposalResponseFromBytes(raw []byte) (ProposalResponse, error)
NewTransaction(creator view.Identity, nonce []byte, txid string, channel string) (Transaction, error)
NewTransactionFromBytes(channel string, raw []byte) (Transaction, error)
}
type TransactionStatusChanged ¶
type TransactionStatusChanged struct {
ThisTopic string
TxID string
VC ValidationCode
}
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 TransientMap ¶
type TxStatusChangeListener ¶
type TxStatusChangeListener interface {
// OnStatusChange is called when the status of a transaction changes
OnStatusChange(txID string, status int) error
}
TxStatusChangeListener is the interface that must be implemented to receive transaction status change notifications
type TxidIterator ¶
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 HasDependencies // Transaction is unknown but has known dependencies )
type Vault ¶
type Vault interface {
// NewQueryExecutor gives handle to a query executor.
// A client can obtain more than one 'QueryExecutor's for parallel execution.
// Any synchronization should be performed at the implementation level if required
NewQueryExecutor() (QueryExecutor, error)
// NewRWSet returns a RWSet for this ledger.
// A client may obtain more than one such simulator; they are made unique
// by way of the supplied txid
NewRWSet(txid string) (RWSet, error)
// GetRWSet returns a RWSet for this ledger whose content is unmarshalled
// from the passed bytes.
// A client may obtain more than one such simulator; they are made unique
// by way of the supplied txid
GetRWSet(txid string, rwset []byte) (RWSet, error)
// GetEphemeralRWSet 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
GetEphemeralRWSet(rwset []byte, namespaces ...string) (RWSet, error)
}
Vault models a key value store that can be updated by committing rwsets