driver

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertificationStorage added in v0.4.0

type CertificationStorage = driver2.CertificationStorage

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)
}

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)

	TokenVault(namespace string) (TokenVault, error)

	// Broadcast sends the passed blob to the network
	Broadcast(context 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(context context.Context, namespace string, IDs []*token.ID) ([][]byte, error)

	// AreTokensSpent retrieves the spent flag for the passed ids
	AreTokensSpent(context 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, startingTxID string, subKey string, timeout time.Duration, stopOnLastTx bool) ([]byte, error)

	// Ledger gives access to the remote ledger
	Ledger() (Ledger, error)

	// ProcessNamespace indicates to the commit pipeline to process all transaction in the passed namespace
	ProcessNamespace(namespace string) error
}

Network models a backend that stores tokens

type QueryEngine added in v0.4.0

type QueryEngine = driver2.QueryEngine

type SpentTokenQueryExecutor added in v0.4.0

type SpentTokenQueryExecutor interface {
	QuerySpentTokens(context 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(context 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 TokenVault added in v0.4.0

type TokenVault interface {
	driver2.Vault

	// DeleteTokens delete the passed tokens in the passed namespace
	DeleteTokens(ids ...*token.ID) error
}

TokenVault models the token vault

type TokenVaultProvider added in v0.4.0

type TokenVaultProvider interface {
	Vault(network, channel, namespace string) (TokenVault, error)
}

type TransientMap

type TransientMap = map[string][]byte

type TxID

type TxID struct {
	Nonce   []byte
	Creator []byte
}

func (*TxID) String

func (t *TxID) String() string

type TxStatus added in v0.4.0

type TxStatus = int

type UnspentTokensIterator

type UnspentTokensIterator = driver2.UnspentTokensIterator

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
)

type Vault

type Vault interface {
	// Status returns the status of the transaction
	Status(id string) (ValidationCode, string, error)

	// DiscardTx discards the transaction with the passed id
	DiscardTx(id string, message string) error
}

Vault models the vault service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL