Documentation
¶
Index ¶
- type AuditInfoStore
- type AuditRegistry
- type BindingStore
- type BlockNum
- type Channel
- type ConfigService
- type EndorseTxStore
- type EnvelopeStore
- type FinalityEvent
- type FinalityListener
- type GetStateOpt
- type IsolationLevel
- type ListenerManager
- type ListenerManagerProvider
- type LockedVaultReader
- type MKey
- type MetaWrites
- type Metadata
- type MetadataStore
- type NamedDriver
- type Namespace
- type Network
- type PKey
- type PageIterator
- type Pagination
- type PersistenceType
- type QueryExecutor
- type RWSet
- type RawValue
- type RawVersion
- type SigDeserializer
- type SigRegistry
- type SigService
- type Signer
- type SignerEntry
- type SignerInfoStore
- type SigningIdentity
- type TransactionFilter
- type TxID
- type TxNum
- type TxStateIterator
- type TxStatus
- type TxStatusCode
- type TxStatusIterator
- type TxValidationStatus
- type UnversionedRead
- type UnversionedValue
- type ValidationCode
- type ValidationCodeProvider
- type Vault
- type VaultMetadataValue
- type VaultRead
- type VaultReader
- type VaultStore
- type VaultValue
- type Verifier
- type VerifyingIdentity
- type VersionedResultsIterator
- type Writes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditInfoStore ¶ added in v0.4.1
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 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 EnvelopeStore ¶ added in v0.4.1
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 MetaWrites ¶ added in v0.4.1
type MetaWrites map[Namespace]map[PKey]VaultMetadataValue
type MetadataStore ¶ added in v0.4.1
type NamedDriver ¶
type NamedDriver[D any] struct { Name PersistenceType Driver D }
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 RawVersion ¶
type RawVersion = []byte
type SigDeserializer ¶
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 SignerInfoStore ¶ added in v0.4.1
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 ¶
TransactionFilter is used to filter unknown transactions. If the filter accepts, the transaction is processed by the commit pipeline anyway.
type TxStateIterator ¶ added in v0.4.1
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 TxValidationStatus ¶
type TxValidationStatus[V comparable] struct { TxID TxID ValidationCode V Message string }
type UnversionedRead ¶ added in v0.4.1
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 Writes ¶ added in v0.4.1
type Writes map[Namespace]map[PKey]VaultValue