driver

package
v0.7.0 Latest Latest
Warning

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

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

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

Jump to

Keyboard shortcuts

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