driver

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 5 Imported by: 32

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditInfoStore added in v0.4.1

type AuditInfoStore interface {
	GetAuditInfo(ctx context.Context, id view.Identity) ([]byte, error)
	PutAuditInfo(ctx context.Context, id view.Identity, info []byte) error
}

type AuditRegistry

type AuditRegistry interface {
	// RegisterAuditInfo binds the passed audit info to the passed identity
	RegisterAuditInfo(ctx context.Context, identity view.Identity, info []byte) error

	// GetAuditInfo returns the audit info associated to the passed identity, nil if not found
	GetAuditInfo(ctx context.Context, identity view.Identity) ([]byte, error)
}

AuditRegistry models a repository of identities' audit information

type BindingStore added in v0.4.1

type BindingStore interface {
	GetLongTerm(ctx context.Context, ephemeral view.Identity) (view.Identity, error)
	HaveSameBinding(ctx context.Context, this, that view.Identity) (bool, error)
	PutBinding(ctx context.Context, ephemeral, longTerm view.Identity) error
}

type BlockNum

type BlockNum = uint64

type Channel

type Channel = string

type ConfigService added in v0.4.1

type ConfigService interface {
	// GetString returns the value associated with the key as a string
	GetString(key string) string
	// GetInt returns the value associated with the key as an integer
	GetInt(key string) int
	// 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
	// GetStringSlice returns the value associated with the key as a slice of strings
	GetStringSlice(key string) []string
	// 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
	// ConfigFileUsed returns the file used to populate the config registry
	ConfigFileUsed() string
	// 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
}

ConfigService models a configuration registry

type EndorseTxStore added in v0.4.1

type EndorseTxStore[K any] interface {
	GetEndorseTx(ctx context.Context, key K) ([]byte, error)
	ExistsEndorseTx(ctx context.Context, key K) (bool, error)
	PutEndorseTx(ctx context.Context, key K, etx []byte) error
}

type EnvelopeStore added in v0.4.1

type EnvelopeStore[K any] interface {
	GetEnvelope(ctx context.Context, key K) ([]byte, error)
	ExistsEnvelope(ctx context.Context, key K) (bool, error)
	PutEnvelope(ctx context.Context, key K, env []byte) error
}

type FinalityEvent

type FinalityEvent[V comparable] struct {
	Ctx               context.Context
	TxID              TxID
	ValidationCode    V
	ValidationMessage string
	Block             BlockNum
	IndexInBlock      TxNum
	Err               error
}

FinalityEvent contains information about the finality of a given transaction

type FinalityListener

type FinalityListener[V comparable] interface {
	// OnStatus is called when the status of a transaction changes, or it is already valid or invalid
	OnStatus(ctx context.Context, txID TxID, status V, statusMessage string)
}

FinalityListener is the interface that must be implemented to receive transaction status notifications

type GetStateOpt

type GetStateOpt int
const (
	FromStorage GetStateOpt = iota
	FromIntermediate
	FromBoth
)

type IsolationLevel added in v0.4.1

type IsolationLevel int
const (
	LevelDefault IsolationLevel = iota
	LevelReadUncommitted
	LevelReadCommitted
	LevelWriteCommitted
	LevelRepeatableRead
	LevelSnapshot
	LevelSerializable
	LevelLinearizable
)

type ListenerManager

type ListenerManager[V comparable] interface {
	AddListener(txID TxID, toAdd FinalityListener[V]) error
	RemoveListener(txID TxID, toRemove FinalityListener[V])
	InvokeListeners(event FinalityEvent[V])
	TxIDs() []TxID
}

type ListenerManagerProvider

type ListenerManagerProvider[V comparable] interface {
	NewManager() ListenerManager[V]
}

type LockedVaultReader added in v0.4.1

type LockedVaultReader interface {
	VaultReader

	// Done releases the lock on the locked resources
	Done() error
}

LockedVaultReader is a VaultReader with a lock on some or all entries

type MKey

type MKey = string

type MetaWrites added in v0.4.1

type MetaWrites map[Namespace]map[PKey]VaultMetadataValue

type Metadata

type Metadata = map[MKey][]byte

type MetadataStore added in v0.4.1

type MetadataStore[K any, M any] interface {
	GetMetadata(ctx context.Context, key K) (M, error)
	ExistMetadata(ctx context.Context, key K) (bool, error)
	PutMetadata(ctx context.Context, key K, transientMap M) error
}

type NamedDriver

type NamedDriver[D any] struct {
	Name   PersistenceType
	Driver D
}

type Namespace

type Namespace = string

type Network

type Network = string

type PKey

type PKey = string

type PageIterator added in v0.4.1

type PageIterator[R comparable] struct {
	Items      iterators.Iterator[R]
	Pagination Pagination
}

PageIterator is an ieterator with support for pagination

type Pagination added in v0.4.1

type Pagination interface {
	// Prev moves the pagination pointer to the prev page
	Prev() (Pagination, error)
	// Next moves the pagination pointer to the next page
	Next() (Pagination, error)
	// Equal checks whether a given pagination struct is of the same type and with the same parameters
	Equal(Pagination) bool
	// Serialize the pagination struct into a buffer
	Serialize() ([]byte, error)
}

Pagination describe a moving page

type PersistenceType

type PersistenceType string

type QueryExecutor

type QueryExecutor interface {
	GetState(ctx context.Context, namespace Namespace, key PKey) (*VaultRead, error)
	GetStateMetadata(ctx context.Context, namespace Namespace, key PKey) (Metadata, RawVersion, error)
	GetStateRange(ctx context.Context, namespace Namespace, startKey PKey, endKey PKey) (VersionedResultsIterator, error)
	Done() error
}

type RWSet

type RWSet interface {
	// IsValid returns true if this rwset is valid.
	// A rwset is valid if:
	// 1. It exists in the vault as valid
	// 2. All the read dependencies are satisfied by the vault
	IsValid() error

	IsClosed() bool

	// Clear remove the passed namespace from this rwset
	Clear(ns Namespace) error

	// AddReadAt adds a read dependency for the given namespace and key at the given version
	AddReadAt(ns Namespace, key string, version RawVersion) error

	// SetState sets the given value for the given namespace and key.
	SetState(namespace Namespace, key PKey, value RawValue) error

	GetState(namespace Namespace, key PKey, opts ...GetStateOpt) (RawValue, error)

	// GetDirectState accesses the state using the query executor without looking into the RWSet.
	// This way we can access the query executor while we have a RWSet already open avoiding nested RLocks.
	GetDirectState(namespace Namespace, key PKey) (RawValue, error)

	// DeleteState deletes the given namespace and key
	DeleteState(namespace Namespace, key PKey) error

	GetStateMetadata(namespace Namespace, key PKey, opts ...GetStateOpt) (Metadata, error)

	// SetStateMetadata sets the metadata associated with an existing key-tuple <namespace, key>
	SetStateMetadata(namespace Namespace, key PKey, metadata Metadata) error

	GetReadKeyAt(ns Namespace, i int) (PKey, 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 Namespace, i int) (PKey, RawValue, error)

	// GetWriteAt returns the i-th write (key, value) in the namespace ns of this rwset.
	GetWriteAt(ns Namespace, i int) (PKey, RawValue, error)

	// NumReads returns the number of reads in the namespace ns  of this rwset.
	NumReads(ns Namespace) int

	// NumWrites returns the number of writes in the namespace ns of this rwset.
	NumWrites(ns Namespace) int

	// Namespaces returns the namespace labels in this rwset.
	Namespaces() []Namespace

	AppendRWSet(raw []byte, nss ...Namespace) error

	Bytes() ([]byte, error)

	Done()

	Equals(rws interface{}, nss ...Namespace) error
}

RWSet models a namespaced versioned read-write set

type RawValue

type RawValue = []byte

type RawVersion

type RawVersion = []byte

type SigDeserializer

type SigDeserializer interface {
	DeserializeVerifier(raw []byte) (Verifier, error)
	DeserializeSigner(raw []byte) (Signer, error)
	Info(raw []byte, auditInfo []byte) (string, error)
}

type SigRegistry

type SigRegistry interface {
	// RegisterSigner binds the passed identity to the passed signer and verifier
	RegisterSigner(ctx context.Context, identity view.Identity, signer Signer, verifier Verifier) error

	// RegisterVerifier binds the passed identity to the passed verifier
	RegisterVerifier(identity view.Identity, verifier Verifier) error
}

type SigService

type SigService interface {
	// GetSigner returns the signer bound to the passed identity
	GetSigner(identity view.Identity) (Signer, error)

	// GetVerifier returns the verifier bound to the passed identity
	GetVerifier(identity view.Identity) (Verifier, error)

	// GetSigningIdentity returns the signer identity bound to the passed identity
	GetSigningIdentity(identity view.Identity) (SigningIdentity, error)

	// IsMe returns true if a signer was ever registered for the passed identity
	IsMe(ctx context.Context, identity view.Identity) bool

	// AreMe returns the hashes of the passed identities that have a signer registered before
	AreMe(ctx context.Context, identities ...view.Identity) []string
}

SigService models a repository of sign and verify keys.

type Signer

type Signer interface {
	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(message []byte) ([]byte, error)
}

Signer is an interface which wraps the Sign method.

type SignerEntry added in v0.4.1

type SignerEntry struct {
	Signer     Signer
	DebugStack []byte
}

type SignerInfoStore added in v0.4.1

type SignerInfoStore interface {
	FilterExistingSigners(ctx context.Context, ids ...view.Identity) ([]view.Identity, error)
	PutSigner(ctx context.Context, id view.Identity) error
}

type SigningIdentity

type SigningIdentity interface {
	VerifyingIdentity

	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(message []byte) ([]byte, error)

	GetPublicVersion() VerifyingIdentity
}

type TransactionFilter

type TransactionFilter interface {
	Accept(txID TxID, env []byte) (bool, error)
}

TransactionFilter is used to filter unknown transactions. If the filter accepts, the transaction is processed by the commit pipeline anyway.

type TxID

type TxID = string

type TxNum

type TxNum = uint64

type TxStateIterator added in v0.4.1

type TxStateIterator = iterators.Iterator[*VaultRead]

type TxStatus added in v0.4.1

type TxStatus struct {
	TxID    TxID
	Code    TxStatusCode
	Message string
}

type TxStatusCode added in v0.4.1

type TxStatusCode int32
const (
	Unknown TxStatusCode = iota
	Valid
	Invalid
	Busy
)

type TxStatusIterator added in v0.4.1

type TxStatusIterator = iterators.Iterator[*TxStatus]

type TxValidationStatus

type TxValidationStatus[V comparable] struct {
	TxID           TxID
	ValidationCode V
	Message        string
}

type UnversionedRead added in v0.4.1

type UnversionedRead struct {
	Key PKey
	Raw RawValue
}

type UnversionedValue added in v0.4.1

type UnversionedValue = RawValue

type ValidationCode

type ValidationCode interface {
	comparable
}

type ValidationCodeProvider

type ValidationCodeProvider[V ValidationCode] interface {
	ToInt32(V) TxStatusCode
	FromInt32(TxStatusCode) V
}

func NewValidationCodeProvider added in v0.4.1

func NewValidationCodeProvider[V ValidationCode](m map[V]TxStatusCode) ValidationCodeProvider[V]

type Vault

type Vault[V comparable] 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(ctx context.Context) (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(ctx context.Context, txID TxID) (RWSet, error)

	// NewRWSetFromBytes creates a new RWSet in the vault 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.
	// Example: alice creates a new RWSet using NewRWSet and marshals and sends the serialized RW set to bob.
	// Then bob creates an identical RWSet using GetRWSet using the marshaled RW set from alice
	NewRWSetFromBytes(ctx context.Context, txID TxID, rwset []byte) (RWSet, error)

	SetDiscarded(ctx context.Context, txID TxID, message string) error

	Status(ctx context.Context, txID TxID) (V, string, error)

	Statuses(ctx context.Context, txIDs ...TxID) ([]TxValidationStatus[V], error)

	// DiscardTx discards the transaction with the given transaction id.
	// If no error occurs, invoking Status on the same transaction id will return the Invalid flag.
	DiscardTx(ctx context.Context, txID TxID, message string) error

	CommitTX(ctx context.Context, txID TxID, block BlockNum, index TxNum) error
}

Vault models a key value store that can be updated by committing rwsets

type VaultMetadataValue added in v0.4.1

type VaultMetadataValue struct {
	Version  RawVersion
	Metadata Metadata
}

type VaultRead added in v0.4.1

type VaultRead struct {
	Key     PKey
	Raw     RawValue
	Version RawVersion
}

type VaultReader added in v0.4.1

type VaultReader interface {
	// GetStateMetadata returns the metadata for the given specific namespace - key pair
	GetStateMetadata(ctx context.Context, namespace Namespace, key PKey) (Metadata, RawVersion, error)

	// GetState returns the state for the given specific namespace - key pair
	GetState(ctx context.Context, namespace Namespace, key PKey) (*VaultRead, error)

	// GetStates returns the states for the given specific namespace - key pairs
	GetStates(ctx context.Context, namespace Namespace, keys ...PKey) (TxStateIterator, error)

	// GetStateRange returns the states for the given specific namespace - key range
	GetStateRange(ctx context.Context, namespace Namespace, startKey, endKey PKey) (TxStateIterator, error)

	// GetAllStates returns all states for a given namespace. Only used for testing purposes.
	GetAllStates(ctx context.Context, namespace Namespace) (TxStateIterator, error)

	// GetLast returns the status of the latest non-pending transaction
	GetLast(ctx context.Context) (*TxStatus, error)

	// GetTxStatus returns the status of the given transaction
	GetTxStatus(ctx context.Context, txID TxID) (*TxStatus, error)

	// GetTxStatuses returns the statuses of the given transactions
	GetTxStatuses(ctx context.Context, txIDs ...TxID) (TxStatusIterator, error)

	// GetAllTxStatuses returns the statuses of the all transactions in the vault
	GetAllTxStatuses(ctx context.Context, pagination Pagination) (*PageIterator[*TxStatus], error)
}

type VaultStore added in v0.4.1

type VaultStore interface {
	VaultReader
	// NewTxLockVaultReader acquires a read lock on a specific transaction.
	// While holding this lock, other routines:
	// - cannot update the transaction states of the locked transactions (based on the isolation level passed)
	// - can read the locked states
	NewTxLockVaultReader(ctx context.Context, txID TxID, isolationLevel IsolationLevel) (LockedVaultReader, error)

	// NewGlobalLockVaultReader acquires a global exclusive read lock on the vault.
	// While holding this lock, other routines:
	// - cannot acquire this read lock (exclusive)
	// - cannot update any transaction states or statuses
	// - can read any transaction
	NewGlobalLockVaultReader(ctx context.Context) (LockedVaultReader, error)

	// Store stores atomically the transaction statuses, writes and metadata writes
	Store(ctx context.Context, txIDs []TxID, writes Writes, metaWrites MetaWrites) error

	// SetStatuses sets the status and message for the given transactions
	SetStatuses(ctx context.Context, code TxStatusCode, message string, txIDs ...TxID) error

	// Close closes the vault store
	Close() error
}

type VaultValue added in v0.4.1

type VaultValue struct {
	Raw     RawValue
	Version RawVersion
}

type Verifier

type Verifier interface {
	// Verify verifies the signature over the passed message.
	Verify(message, sigma []byte) error
}

Verifier is an interface which wraps the Verify method.

type VerifyingIdentity

type VerifyingIdentity interface {
	// Serialize returns the byte representation of this identity
	Serialize() ([]byte, error)

	// Verify verifies the signature over the passed message.
	Verify(message []byte, signature []byte) error
}

type VersionedResultsIterator

type VersionedResultsIterator = iterators.Iterator[*VaultRead]

type Writes added in v0.4.1

type Writes map[Namespace]map[PKey]VaultValue

Jump to

Keyboard shortcuts

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