Documentation
¶
Index ¶
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(sp view.ServiceProvider, network, channel string) (Network, error)
}
Driver models the network driver factory
type Envelope ¶
type Envelope interface {
// Results returns the results
Results() []byte
// 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
// Nonce returns the nonce, if any
Nonce() []byte
// Creator returns the creator of this envelope
Creator() []byte
// String returns the string representation of this envelope
String() string
}
Envelope models a network envelope
type Ledger ¶
type Ledger interface {
// Status returns the status of the transaction
Status(id string) (ValidationCode, 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
}
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
// Vault returns the vault for the passed namespace. If namespaces are not supported,
// the argument is ignored.
Vault(namespace string) (Vault, error)
// GetRWSet returns the read-write set for the passed id and marshalled set
GetRWSet(id string, results []byte) (RWSet, error)
// StoreEnvelope stores locally the passed envelope mapping it to the passed id
StoreEnvelope(id string, env []byte) error
// EnvelopeExists returns true if an envelope exists for the passed id, false otherwise
EnvelopeExists(id string) bool
// Broadcast sends the passed blob to the network
Broadcast(blob interface{}) 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(id string, endpoints ...view.Identity) error
// 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, id string) error
// NewEnvelope returns a new instance of an envelope
NewEnvelope() Envelope
// StoreTransient stores the passed transient map and maps it to the passed id
StoreTransient(id string, transient TransientMap) error
// TransientExists returns true if a transient map exists for the passed id, false otherwise
TransientExists(id string) bool
// GetTransient retrieves the transient map bound to the passed id
GetTransient(id string) (TransientMap, error)
// 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(context view.Context, namespace string, IDs []*token.ID) ([][]byte, error)
// AreTokensSpent retrieves the spent flag for the passed ids
AreTokensSpent(context view.Context, namespace string, IDs []string) ([]bool, error)
// LocalMembership returns the local membership
LocalMembership() LocalMembership
// GetEnrollmentID returns the enrollment id of the passed identity
GetEnrollmentID(raw []byte) (string, error)
// SubscribeTxStatusChanges registers a listener for transaction status changes for the passed id
SubscribeTxStatusChanges(txID string, listener TxStatusChangeListener) error
// UnsubscribeTxStatusChanges unregisters a listener for transaction status changes for the passed id
UnsubscribeTxStatusChanges(id string, listener TxStatusChangeListener) 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.
LookupTransferMetadataKey(namespace string, startingTxID string, subKey string, timeout time.Duration) ([]byte, error)
// Ledger gives access to the remote ledger
Ledger() (Ledger, error)
}
Network models a backend that stores tokens
type RWSet ¶
type RWSet interface {
// Done signals the end of the manipulation of this read-write set
Done()
}
RWSet models a transaction's read-write set
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 UnspentTokensIterator ¶
type UnspentTokensIterator interface {
// Close must be invoked when the iterator is not needed anymore
Close()
// Next returns the next available unspent tokens. If next is nil, no more tokens are available.
Next() (*token.UnspentToken, error)
}
UnspentTokensIterator models an iterator of unspent tokens
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 HasDependencies // Transaction is unknown but has known dependencies )
type Vault ¶
type Vault interface {
// GetLastTxID returns the last transaction ID committed into the vault
GetLastTxID() (string, error)
// UnspentTokensIteratorBy returns an iterator of unspent tokens owned by the passed wallet id and whose type is the passed on.
// The token type can be empty. In that case, tokens of any type are returned.
UnspentTokensIteratorBy(walletID, tokenType string) (UnspentTokensIterator, error)
// UnspentTokensIterator returns an iterator over all unspent tokens
UnspentTokensIterator() (UnspentTokensIterator, error)
// ListUnspentTokens returns the list of all unspent tokens
ListUnspentTokens() (*token.UnspentTokens, error)
// Exists returns true if the token exists in the vault
Exists(id *token.ID) bool
// Store the passed token certifications, if applicable
Store(certifications map[*token.ID][]byte) error
// TokenVault returns the token vault
TokenVault() *vault.Vault
// Status returns the status of the transaction
Status(id string) (ValidationCode, error)
// DiscardTx discards the transaction with the passed id
DiscardTx(id string) error
}
Vault models the vault service
Click to show internal directories.
Click to hide internal directories.