Documentation
¶
Index ¶
- type Driver
- type Envelope
- type FinalityListener
- type FinalityListenerManager
- type Ledger
- type LocalMembership
- type Network
- type SpentTokenQueryExecutor
- type SpentTokenQueryExecutorProvider
- type TokenQueryExecutor
- type TokenQueryExecutorProvider
- type TransientMap
- type TxID
- type TxStatus
- type ValidationCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface {
// New returns a new network instance for the passed network and channel (if applicable)
New(network, channel string) (Network, error)
}
Driver models the network driver factory
type Envelope ¶
type Envelope interface {
// Bytes marshals the envelope to bytes
Bytes() ([]byte, error)
// FromBytes unmarshals the envelope from bytes
FromBytes([]byte) error
// TxID returns the ID of this envelope
TxID() string
// String returns the string representation of this envelope
String() string
}
Envelope models a network envelope
type FinalityListener ¶ added in v0.4.0
type FinalityListener interface {
// OnStatus is called when the status of a transaction changes
OnStatus(ctx context.Context, txID string, status int, message string, tokenRequestHash []byte)
}
FinalityListener is the interface that must be implemented to receive transaction status change notifications
type FinalityListenerManager ¶ added in v0.4.0
type FinalityListenerManager interface {
// 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.
// If the transaction id is empty, the listener will be called on status changes of any transaction.
// In this case, the listener is not removed
AddFinalityListener(namespace string, txID string, listener FinalityListener) error
// RemoveFinalityListener unregisters the passed listener.
RemoveFinalityListener(id string, listener FinalityListener) error
}
type Ledger ¶
type Ledger interface {
// Status returns the status of the transaction
Status(id string) (ValidationCode, error)
// GetStates returns the value corresponding to the given keys stored in the given namespace.
GetStates(ctx context.Context, namespace string, keys ...string) ([][]byte, error)
// TransferMetadataKey returns the transfer metadata key associated to the given key
TransferMetadataKey(k string) (string, error)
}
Ledger models the ledger service
type LocalMembership ¶
type LocalMembership interface {
// DefaultIdentity returns the default FSC node identity
DefaultIdentity() view.Identity
// AnonymousIdentity returns a fresh anonymous identity
AnonymousIdentity() (view.Identity, error)
}
LocalMembership models the local membership service
type Network ¶
type Network interface {
// Name returns the name of the network
Name() string
// Channel returns the channel name, empty if not applicable
Channel() string
Normalize(opt *token2.ServiceOptions) (*token2.ServiceOptions, error)
Connect(ns string) ([]token2.ServiceOption, error)
// Broadcast sends the passed blob to the network
Broadcast(ctx context.Context, blob interface{}) error
// NewEnvelope returns a new instance of an envelope
NewEnvelope() Envelope
// RequestApproval requests approval for the passed request and returns the returned envelope
RequestApproval(context view.Context, tms *token2.ManagementService, requestRaw []byte, signer view.Identity, txID TxID) (Envelope, error)
// ComputeTxID computes the network transaction id from the passed abstract transaction id
ComputeTxID(id *TxID) string
// FetchPublicParameters returns the public parameters for the network.
// If namespace is not supported, the argument is ignored.
FetchPublicParameters(namespace string) ([]byte, error)
// QueryTokens retrieves the token content for the passed token ids
QueryTokens(ctx context.Context, namespace string, IDs []*token.ID) ([][]byte, error)
// AreTokensSpent retrieves the spent flag for the passed ids
AreTokensSpent(ctx context.Context, namespace string, tokenIDs []*token.ID, meta []string) ([]bool, error)
// LocalMembership returns the local membership
LocalMembership() LocalMembership
// 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.
// If the transaction id is empty, the listener will be called on status changes of any transaction.
// In this case, the listener is not removed
AddFinalityListener(namespace string, txID string, listener FinalityListener) error
// RemoveFinalityListener unregisters the passed listener.
RemoveFinalityListener(id string, listener FinalityListener) error
// LookupTransferMetadataKey searches for a transfer metadata key containing the passed sub-key starting from the passed transaction id in the given namespace.
// The operation gets canceled if the passed timeout elapses or, if stopOnLastTx is true, when the last transaction in the vault is reached.
LookupTransferMetadataKey(namespace string, key string, timeout time.Duration) ([]byte, error)
// Ledger gives access to the remote ledger
Ledger() (Ledger, error)
}
Network models a backend that stores tokens
type SpentTokenQueryExecutor ¶ added in v0.4.0
type SpentTokenQueryExecutor interface {
QuerySpentTokens(ctx context.Context, namespace string, IDs []*token2.ID, meta []string) ([]bool, error)
}
SpentTokenQueryExecutor queries the global state/ledger for tokens
type SpentTokenQueryExecutorProvider ¶ added in v0.4.0
type SpentTokenQueryExecutorProvider interface {
GetSpentExecutor(network, channel string) (SpentTokenQueryExecutor, error)
}
type TokenQueryExecutor ¶ added in v0.4.0
type TokenQueryExecutor interface {
QueryTokens(ctx context.Context, namespace string, IDs []*token2.ID) ([][]byte, error)
}
TokenQueryExecutor queries the global state/ledger for tokens
type TokenQueryExecutorProvider ¶ added in v0.4.0
type TokenQueryExecutorProvider interface {
GetExecutor(network, channel string) (TokenQueryExecutor, error)
}
type TransientMap ¶
type ValidationCode ¶
type ValidationCode = int
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 )
Click to show internal directories.
Click to hide internal directories.