Documentation
¶
Overview ¶
Copyright IBM Corp. All Rights Reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func Close(closer Closer)
- func CloseFunc(closer func() error)
- func HasMovementsParams(params driver2.QueryMovementsParams) cond.Condition
- func HasTokenDetails(params driver2.QueryTokenDetailsParams, tokenTable common.Table) cond.Condition
- func HasTokens(colTxID, colIdx common.FieldName, ids ...*token.ID) cond.Condition
- func HasTransactionParams(params driver2.QueryTransactionsParams, table common.Table) cond.Condition
- func HasValidationParams(params driver2.QueryValidationRecordsParams, tableName string) cond.Condition
- func IsExpiredToken(tokenRequests, tokenLocks common3.Table, leaseExpiry time.Duration) cond.Condition
- func RunTokenStoreBenchmarks(b *testing.B, store *TokenStore)
- func SeedBenchTokens(b *testing.B, store *TokenStore, n int)
- func TestAWAddMovement(t *testing.T, store transactionsStoreConstructor)
- func TestAWAddTokenRequest(t *testing.T, store transactionsStoreConstructor)
- func TestAWAddTransaction(t *testing.T, store transactionsStoreConstructor)
- func TestAWAddValidationRecord(t *testing.T, store endorserStoreConstructor)
- func TestAddTransactionEndorsementAck(t *testing.T, store transactionsStoreConstructor)
- func TestGetStatus(t *testing.T, store transactionsStoreConstructor)
- func TestGetStatusEndorser(t *testing.T, store endorserStoreConstructor)
- func TestGetTokenRequest(t *testing.T, store transactionsStoreConstructor)
- func TestGetTransactionEndorsementAcks(t *testing.T, store transactionsStoreConstructor)
- func TestGetWalletID(t *testing.T, store walletStoreConstructor)
- func TestGetWalletIDs(t *testing.T, store walletStoreConstructor)
- func TestIdentityExists(t *testing.T, store walletStoreConstructor)
- func TestLoadMeta(t *testing.T, store walletStoreConstructor)
- func TestLock(t *testing.T, store tokenLockStoreConstructor)
- func TestQueryMovements(t *testing.T, store transactionsStoreConstructor, ...)
- func TestQueryTokenRequests(t *testing.T, store transactionsStoreConstructor, ...)
- func TestQueryTransactions(t *testing.T, store transactionsStoreConstructor)
- func TestQueryValidations(t *testing.T, store endorserStoreConstructor, traits QueryConstructorTraits)
- func TestSetStatus(t *testing.T, store transactionsStoreConstructor)
- func TestSetStatusEndorser(t *testing.T, store endorserStoreConstructor)
- func TestStoreIdentity(t *testing.T, store walletStoreConstructor)
- func TestStoreIdentityIdempotent(t *testing.T, store walletStoreConstructor)
- func TestUnlockByTxID(t *testing.T, store tokenLockStoreConstructor)
- type AnyUUID
- type BigInt
- type Closer
- type Delete
- type EndorserStore
- func (db *EndorserStore) Close() error
- func (db *EndorserStore) CreateSchema() error
- func (db *EndorserStore) GetSchema() string
- func (db *EndorserStore) GetStatus(ctx context.Context, txID string) (dbdriver.TxStatus, string, error)
- func (db *EndorserStore) NewEndorserStoreTransaction() (dbdriver.EndorserStoreTransaction, error)
- func (db *EndorserStore) QueryValidations(ctx context.Context, params dbdriver.QueryValidationRecordsParams) (dbdriver.ValidationRecordsIterator, error)
- type EndorserStoreTransaction
- func (w *EndorserStoreTransaction) AddValidationRecord(ctx context.Context, txID string, tokenRequest []byte, meta map[string][]byte, ...) error
- func (w *EndorserStoreTransaction) Commit() error
- func (w *EndorserStoreTransaction) Impl() dbdriver.TransactionImpl
- func (w *EndorserStoreTransaction) Rollback()
- func (w *EndorserStoreTransaction) SetStatus(ctx context.Context, txID string, status dbdriver.TxStatus, message string) error
- type IdentityStore
- func NewCachedIdentityStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, ...) (*IdentityStore, error)
- func NewIdentityStore(readDB, writeDB *sql.DB, tables TableNames, signerInfoCache cache[bool], ...) (*IdentityStore, error)
- func NewIdentityStoreWithNotifier(readDB, writeDB *sql.DB, tables TableNames, signerInfoCache cache[bool], ...) (*IdentityStore, error)
- func NewNoCacheIdentityStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, ...) (*IdentityStore, error)
- func (db *IdentityStore) AddConfiguration(ctx context.Context, wp driver.IdentityConfiguration) error
- func (db *IdentityStore) Close() error
- func (db *IdentityStore) ConfigurationExists(ctx context.Context, id, typ, url string) (bool, error)
- func (db *IdentityStore) CreateSchema() error
- func (db *IdentityStore) GetAuditInfo(ctx context.Context, id []byte) ([]byte, error)
- func (db *IdentityStore) GetConfiguration(ctx context.Context, id, typ, url string) (*driver.IdentityConfiguration, error)
- func (db *IdentityStore) GetExistingSignerInfo(ctx context.Context, ids ...tdriver.Identity) ([]string, error)
- func (db *IdentityStore) GetSchema() string
- func (db *IdentityStore) GetSignerInfo(ctx context.Context, identity []byte) ([]byte, error)
- func (db *IdentityStore) GetTokenInfo(ctx context.Context, id []byte) ([]byte, []byte, error)
- func (db *IdentityStore) IterateSigners(ctx context.Context, offset, limit int) ([]idriver.SignerEntry, error)
- func (db *IdentityStore) IteratorConfigurations(ctx context.Context, configurationType string) (idriver.IdentityConfigurationIterator, error)
- func (db *IdentityStore) Notifier() (idriver.IdentityConfigurationNotifier, error)
- func (db *IdentityStore) RegisterIdentityDescriptor(ctx context.Context, descriptor *idriver.IdentityDescriptor, ...) error
- func (db *IdentityStore) SignerInfoExists(ctx context.Context, id []byte) (bool, error)
- func (db *IdentityStore) StoreIdentityData(ctx context.Context, id []byte, identityAudit []byte, tokenMetadata []byte, ...) error
- func (db *IdentityStore) StoreSignerInfo(ctx context.Context, id tdriver.Identity, info []byte) error
- type Insert
- type KeystoreStore
- func (db *KeystoreStore) Close() error
- func (db *KeystoreStore) CreateSchema() error
- func (db *KeystoreStore) Delete(key string) error
- func (db *KeystoreStore) Get(key string, state any) error
- func (db *KeystoreStore) GetRaw(key string) ([]byte, error)
- func (db *KeystoreStore) GetSchema() string
- func (db *KeystoreStore) Put(key string, state any) error
- type PersistenceConstructor
- type QueryConstructorTraits
- type Select
- type StorageConfig
- type TableNameCreator
- type TableNames
- func GetTableNames(prefix string, params ...string) (TableNames, error)
- func GetTableNamesWithConfig(prefix string, cfg StorageConfig, params ...string) (TableNames, error)
- func GetTableNamesWithOverrides(prefix string, overrides TableNamesConfig, params ...string) (TableNames, error)
- func GetTableNamesWithOverridesSkipPrefix(prefix string, overrides TableNamesConfig, params ...string) (TableNames, error)
- type TableNamesConfig
- type TokenLockStore
- func (db *TokenLockStore) Close() error
- func (db *TokenLockStore) CreateSchema() error
- func (db *TokenLockStore) GetSchema() string
- func (db *TokenLockStore) Lock(ctx context.Context, tokenID *token.ID, consumerTxID transaction.ID) error
- func (db *TokenLockStore) UnlockByTxID(ctx context.Context, consumerTxID transaction.ID) error
- type TokenStore
- func (db *TokenStore) AcquireCleanupLeadership(ctx context.Context, lockID int64) (driver.CleanupLeadership, bool, error)
- func (db *TokenStore) Balance(ctx context.Context, walletID string, typ token.Type) (*big.Int, error)
- func (db *TokenStore) Close() error
- func (db *TokenStore) ContinueTokenDBTransaction(tx driver.Transaction) (driver.TokenStoreTransaction, error)
- func (db *TokenStore) CreateSchema() error
- func (db *TokenStore) DeleteTokens(ctx context.Context, deletedBy string, ids ...*token.ID) error
- func (db *TokenStore) ExistsCertification(ctx context.Context, tokenID *token.ID) bool
- func (db *TokenStore) GetAllTokenInfos(ctx context.Context, ids []*token.ID) ([][]byte, error)
- func (db *TokenStore) GetCertifications(ctx context.Context, ids []*token.ID) ([][]byte, error)
- func (db *TokenStore) GetDeletedTokensPendingSKICleanup(ctx context.Context, olderThan time.Duration, limit int) ([]driver.DeletedToken, error)
- func (db *TokenStore) GetSchema() string
- func (db *TokenStore) GetTokenMetadata(ctx context.Context, ids []*token.ID) ([][]byte, error)
- func (db *TokenStore) GetTokenOutputs(ctx context.Context, ids []*token.ID, callback tdriver.QueryCallbackFunc) error
- func (db *TokenStore) GetTokenOutputsAndMeta(ctx context.Context, ids []*token.ID) ([][]byte, [][]byte, []token.Format, error)
- func (db *TokenStore) GetTokens(ctx context.Context, inputs ...*token.ID) ([]*token.Token, error)
- func (db *TokenStore) HasTokenForIdentity(ctx context.Context, ownerIdentity []byte, ownerType string) (bool, error)
- func (db *TokenStore) IsMine(ctx context.Context, txID string, index uint64) (bool, error)
- func (db *TokenStore) ListAuditTokens(ctx context.Context, ids ...*token.ID) ([]*token.Token, error)
- func (db *TokenStore) ListHistoryIssuedTokens(ctx context.Context) (*token.IssuedTokens, error)
- func (db *TokenStore) ListUnspentTokens(ctx context.Context) (*token.UnspentTokens, error)
- func (db *TokenStore) ListUnspentTokensBy(ctx context.Context, walletID string, typ token.Type) (*token.UnspentTokens, error)
- func (db *TokenStore) ListUnspentTokensByWallets(ctx context.Context, walletIDs []string, typ token.Type) (map[string]*token.UnspentTokens, error)
- func (db *TokenStore) MarkTokenCleaned(ctx context.Context, txID string, index uint64, cleanedBy string) error
- func (db *TokenStore) NewTokenDBTransaction() (driver.TokenStoreTransaction, error)
- func (db *TokenStore) Notifier() (driver.TokenNotifier, error)
- func (db *TokenStore) PublicParams(ctx context.Context) ([]byte, error)
- func (db *TokenStore) PublicParamsByHash(ctx context.Context, rawHash tdriver.PPHash) ([]byte, error)
- func (db *TokenStore) QueryTokenDetails(ctx context.Context, params driver.QueryTokenDetailsParams) ([]driver.TokenDetails, error)
- func (db *TokenStore) SetSupportedTokenFormats(formats []token.Format) error
- func (db *TokenStore) SpendableTokensIteratorBy(ctx context.Context, walletID string, typ token.Type) (tdriver.SpendableTokensIterator, error)
- func (db *TokenStore) StoreCertifications(ctx context.Context, certifications map[*token.ID][]byte) error
- func (db *TokenStore) StorePublicParams(ctx context.Context, raw []byte) error
- func (db *TokenStore) StoreToken(ctx context.Context, tr driver.TokenRecord, owners []string) (err error)
- func (db *TokenStore) TransactionExists(ctx context.Context, id string) (bool, error)
- func (db *TokenStore) UnspentLedgerTokensIteratorBy(ctx context.Context) (tdriver.LedgerTokensIterator, error)
- func (db *TokenStore) UnspentTokensIterator(ctx context.Context) (tdriver.UnspentTokensIterator, error)
- func (db *TokenStore) UnspentTokensIteratorBy(ctx context.Context, walletID string, tokenType token.Type) (tdriver.UnspentTokensIterator, error)
- func (db *TokenStore) UnsupportedTokensIteratorBy(ctx context.Context, walletID string, tokenType token.Type) (tdriver.UnsupportedTokensIterator, error)
- func (db *TokenStore) WhoDeletedTokens(ctx context.Context, inputs ...*token.ID) ([]string, []bool, error)
- type TokenTransaction
- func (t *TokenTransaction) Commit() error
- func (t *TokenTransaction) Delete(ctx context.Context, tokenID token.ID, deletedBy string) error
- func (t *TokenTransaction) GetToken(ctx context.Context, tokenID token.ID, includeDeleted bool) (*token.Token, []string, error)
- func (t *TokenTransaction) Rollback() error
- func (t *TokenTransaction) SetSpendable(ctx context.Context, tokenID token.ID, spendable bool) error
- func (t *TokenTransaction) SetSpendableBySupportedTokenFormats(ctx context.Context, formats []token.Format) error
- func (t *TokenTransaction) StoreToken(ctx context.Context, tr driver.TokenRecord, owners []string) error
- type TransactionStore
- func NewAuditTransactionStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, ...) (*TransactionStore, error)
- func NewOwnerTransactionStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, ...) (*TransactionStore, error)
- func NewTransactionStoreWithNotifierAndRecovery(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, ...) (*TransactionStore, error)
- func (db *TransactionStore) AcquireRecoveryLeadership(ctx context.Context, lockID int64) (dbdriver.RecoveryLeadership, bool, error)
- func (db *TransactionStore) AddTransactionEndorsementAck(ctx context.Context, txID string, endorser token.Identity, sigma []byte) (err error)
- func (db *TransactionStore) ClaimPendingTransactions(ctx context.Context, params dbdriver.RecoveryClaimParams) ([]*dbdriver.RecoveryClaim, error)
- func (db *TransactionStore) Close() error
- func (db *TransactionStore) CreateSchema() error
- func (db *TransactionStore) GetSchema() string
- func (db *TransactionStore) GetStatus(ctx context.Context, txID string) (dbdriver.TxStatus, string, error)
- func (db *TransactionStore) GetTokenRequest(ctx context.Context, txID string) ([]byte, error)
- func (db *TransactionStore) GetTokenRequests(ctx context.Context, txIDs []string) (map[string][]byte, error)
- func (db *TransactionStore) GetTransactionEndorsementAcks(ctx context.Context, txID string) (map[string][]byte, error)
- func (db *TransactionStore) NewTransactionStoreTransaction() (dbdriver.TransactionStoreTransaction, error)
- func (db *TransactionStore) Notifier() (dbdriver.TransactionNotifier, error)
- func (s *TransactionStore) PrefixedTableName(name string) string
- func (db *TransactionStore) QueryMovements(ctx context.Context, params dbdriver.QueryMovementsParams) (res []*dbdriver.MovementRecord, err error)
- func (db *TransactionStore) QueryTokenRequests(ctx context.Context, params dbdriver.QueryTokenRequestsParams) (dbdriver.TokenRequestIterator, error)
- func (db *TransactionStore) QueryTransactions(ctx context.Context, params dbdriver.QueryTransactionsParams, ...) (*driver3.PageIterator[*dbdriver.TransactionRecord], error)
- func (db *TransactionStore) ReleaseRecoveryClaim(context.Context, string, string, string) error
- func (db *TransactionStore) SetStatus(ctx context.Context, txID string, status dbdriver.TxStatus, message string) error
- type TransactionStoreTransaction
- func (w *TransactionStoreTransaction) AddMovement(ctx context.Context, rs ...dbdriver.MovementRecord) error
- func (w *TransactionStoreTransaction) AddTokenRequest(ctx context.Context, txID string, tr []byte, ...) error
- func (w *TransactionStoreTransaction) AddTransaction(ctx context.Context, rs ...dbdriver.TransactionRecord) error
- func (w *TransactionStoreTransaction) Commit() error
- func (w *TransactionStoreTransaction) Impl() dbdriver.TransactionImpl
- func (w *TransactionStoreTransaction) Rollback()
- func (w *TransactionStoreTransaction) SetStatus(ctx context.Context, txID string, status dbdriver.TxStatus, message string) error
- type Update
- type WalletStore
- func (db *WalletStore) Close() error
- func (db *WalletStore) CreateSchema() error
- func (db *WalletStore) GetSchema() string
- func (db *WalletStore) GetWalletID(ctx context.Context, identity token.Identity, roleID int) (driver.WalletID, error)
- func (db *WalletStore) GetWalletIDs(ctx context.Context, roleID int) ([]driver.WalletID, error)
- func (db *WalletStore) IdentityExists(ctx context.Context, identity token.Identity, wID driver.WalletID, roleID int) bool
- func (db *WalletStore) LoadMeta(ctx context.Context, identity token.Identity, wID driver.WalletID, roleID int) ([]byte, error)
- func (db *WalletStore) StoreIdentity(ctx context.Context, identity token.Identity, eID string, wID driver.WalletID, ...) error
Constants ¶
const ( // ConfigKeyTableNames is the absolute configuration key for global SQL table name overrides. // // This key is resolved against the root configuration provider (not a TMS-scoped // configuration), so it applies to all TMS instances on the node and maps directly // to token.storage.tableNames in the configuration file. // // Example YAML: // // token: // storage: // tableNames: // id_signers: identity_signers // tokens: my_tokens ConfigKeyTableNames = "token.storage.tableNames" // ConfigKeySkipPrefix is the absolute configuration key for disabling the // FSC-generated prefix on SQL table names. // // When set to true, table names are produced without any prefix, regardless // of what prefix is supplied at runtime. Default is false. // // Example YAML: // // token: // storage: // skipPrefix: true ConfigKeySkipPrefix = "token.storage.skipPrefix" )
const ( SelectStatement = `SELECT` SelectDistinctStatement = `SELECT DISTINCT` InsertStatement = `INSERT INTO` UpdateStatement = `UPDATE` DeleteStatement = `DELETE FROM` )
Variables ¶
This section is empty.
Functions ¶
func HasMovementsParams ¶
func HasMovementsParams(params driver2.QueryMovementsParams) cond.Condition
func HasTokenDetails ¶
func HasTransactionParams ¶
func HasValidationParams ¶
func HasValidationParams(params driver2.QueryValidationRecordsParams, tableName string) cond.Condition
func IsExpiredToken ¶
func RunTokenStoreBenchmarks ¶
func RunTokenStoreBenchmarks(b *testing.B, store *TokenStore)
func SeedBenchTokens ¶
func SeedBenchTokens(b *testing.B, store *TokenStore, n int)
func TestAWAddMovement ¶
func TestAWAddTokenRequest ¶
func TestAWAddTransaction ¶
func TestGetStatus ¶
func TestGetStatusEndorser ¶
func TestGetTokenRequest ¶
func TestGetWalletID ¶
func TestGetWalletIDs ¶
func TestIdentityExists ¶
func TestLoadMeta ¶
func TestQueryMovements ¶
func TestQueryMovements(t *testing.T, store transactionsStoreConstructor, traits QueryConstructorTraits)
func TestQueryTokenRequests ¶
func TestQueryTokenRequests(t *testing.T, store transactionsStoreConstructor, traits QueryConstructorTraits)
func TestQueryTransactions ¶
func TestQueryValidations ¶
func TestQueryValidations(t *testing.T, store endorserStoreConstructor, traits QueryConstructorTraits)
func TestSetStatus ¶
func TestSetStatusEndorser ¶
func TestStoreIdentity ¶
func TestUnlockByTxID ¶
Types ¶
type BigInt ¶
BigInt is a custom wrapper around math/big.Int that implements sql.Scanner for reading NUMERIC values from the DB
type EndorserStore ¶
type EndorserStore struct {
// contains filtered or unexported fields
}
EndorserStore manages validation records for token transaction endorsements
func NewEndorserStore ¶
func NewEndorserStore( readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, pi common3.PagInterpreter, ) (*EndorserStore, error)
NewEndorserStore creates a new EndorserStore
func (*EndorserStore) Close ¶
func (db *EndorserStore) Close() error
Close closes the database connections
func (*EndorserStore) CreateSchema ¶
func (db *EndorserStore) CreateSchema() error
CreateSchema creates the database schema for the endorser store
func (*EndorserStore) GetSchema ¶
func (db *EndorserStore) GetSchema() string
GetSchema returns the SQL schema for creating the endorser store tables
func (*EndorserStore) GetStatus ¶
func (db *EndorserStore) GetStatus(ctx context.Context, txID string) (dbdriver.TxStatus, string, error)
GetStatus returns the status of a validation record
func (*EndorserStore) NewEndorserStoreTransaction ¶
func (db *EndorserStore) NewEndorserStoreTransaction() (dbdriver.EndorserStoreTransaction, error)
NewEndorserStoreTransaction creates a new transaction for endorser operations
func (*EndorserStore) QueryValidations ¶
func (db *EndorserStore) QueryValidations(ctx context.Context, params dbdriver.QueryValidationRecordsParams) (dbdriver.ValidationRecordsIterator, error)
QueryValidations returns an iterator over validation records matching the given params
type EndorserStoreTransaction ¶
type EndorserStoreTransaction struct {
// contains filtered or unexported fields
}
EndorserStoreTransaction represents a database transaction for endorser operations
func (*EndorserStoreTransaction) AddValidationRecord ¶
func (w *EndorserStoreTransaction) AddValidationRecord(ctx context.Context, txID string, tokenRequest []byte, meta map[string][]byte, ppHash driver2.PPHash) error
AddValidationRecord adds a validation record to the database
func (*EndorserStoreTransaction) Commit ¶
func (w *EndorserStoreTransaction) Commit() error
Commit commits the transaction
func (*EndorserStoreTransaction) Impl ¶
func (w *EndorserStoreTransaction) Impl() dbdriver.TransactionImpl
Impl returns the underlying transaction implementation
func (*EndorserStoreTransaction) Rollback ¶
func (w *EndorserStoreTransaction) Rollback()
Rollback rolls back the transaction
type IdentityStore ¶
type IdentityStore struct {
// contains filtered or unexported fields
}
IdentityStore is a SQL-backed implementation of the IdentityStore interface.
func NewCachedIdentityStore ¶
func NewCachedIdentityStore( readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, errorWrapper driver2.SQLErrorWrapper, ) (*IdentityStore, error)
func NewIdentityStore ¶
func NewIdentityStore( readDB, writeDB *sql.DB, tables TableNames, signerInfoCache cache[bool], auditInfoCache cache[[]byte], ci common3.CondInterpreter, errorWrapper driver2.SQLErrorWrapper, ) (*IdentityStore, error)
func NewIdentityStoreWithNotifier ¶
func NewIdentityStoreWithNotifier( readDB, writeDB *sql.DB, tables TableNames, signerInfoCache cache[bool], auditInfoCache cache[[]byte], ci common3.CondInterpreter, errorWrapper driver2.SQLErrorWrapper, notifier idriver.IdentityConfigurationNotifier, ) (*IdentityStore, error)
NewIdentityStoreWithNotifier creates a new IdentityStore with a notifier.
func NewNoCacheIdentityStore ¶
func NewNoCacheIdentityStore( readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, errorWrapper driver2.SQLErrorWrapper, ) (*IdentityStore, error)
func (*IdentityStore) AddConfiguration ¶
func (db *IdentityStore) AddConfiguration(ctx context.Context, wp driver.IdentityConfiguration) error
AddConfiguration stores an identity configuration in the database. It also enqueues an event to the notifier if available.
func (*IdentityStore) Close ¶
func (db *IdentityStore) Close() error
func (*IdentityStore) ConfigurationExists ¶
func (*IdentityStore) CreateSchema ¶
func (db *IdentityStore) CreateSchema() error
func (*IdentityStore) GetAuditInfo ¶
func (*IdentityStore) GetConfiguration ¶
func (db *IdentityStore) GetConfiguration(ctx context.Context, id, typ, url string) (*driver.IdentityConfiguration, error)
GetConfiguration returns the configuration with the given id, type, and url.
func (*IdentityStore) GetExistingSignerInfo ¶
func (*IdentityStore) GetSchema ¶
func (db *IdentityStore) GetSchema() string
func (*IdentityStore) GetSignerInfo ¶
func (*IdentityStore) GetTokenInfo ¶
func (*IdentityStore) IterateSigners ¶
func (db *IdentityStore) IterateSigners(ctx context.Context, offset, limit int) ([]idriver.SignerEntry, error)
IterateSigners returns a page of SignerEntry values from the Signers table, ordered by identity_hash, starting at the given offset and returning at most limit entries.
func (*IdentityStore) IteratorConfigurations ¶
func (db *IdentityStore) IteratorConfigurations(ctx context.Context, configurationType string) (idriver.IdentityConfigurationIterator, error)
IteratorConfigurations returns an iterator to all configurations of the given type.
func (*IdentityStore) Notifier ¶
func (db *IdentityStore) Notifier() (idriver.IdentityConfigurationNotifier, error)
Notifier returns the IdentityNotifier associated with this store.
func (*IdentityStore) RegisterIdentityDescriptor ¶
func (db *IdentityStore) RegisterIdentityDescriptor(ctx context.Context, descriptor *idriver.IdentityDescriptor, alias tdriver.Identity) error
func (*IdentityStore) SignerInfoExists ¶
func (*IdentityStore) StoreIdentityData ¶
func (*IdentityStore) StoreSignerInfo ¶
type KeystoreStore ¶
type KeystoreStore struct {
// contains filtered or unexported fields
}
func NewKeystoreStore ¶
func NewKeystoreStore(readDB, writeDB *sql.DB, tables TableNames, ci qcommon.CondInterpreter, errorWrapper driver.SQLErrorWrapper) (*KeystoreStore, error)
func (*KeystoreStore) Close ¶
func (db *KeystoreStore) Close() error
func (*KeystoreStore) CreateSchema ¶
func (db *KeystoreStore) CreateSchema() error
func (*KeystoreStore) Delete ¶
func (db *KeystoreStore) Delete(key string) error
func (*KeystoreStore) GetSchema ¶
func (db *KeystoreStore) GetSchema() string
type PersistenceConstructor ¶
type QueryConstructorTraits ¶
type Select ¶
type Select struct {
// contains filtered or unexported fields
}
func NewSelectDistinct ¶
type StorageConfig ¶
type StorageConfig struct {
// TableNames contains optional short-code overrides for individual table names.
TableNames TableNamesConfig
// SkipPrefix disables the FSC-generated prefix on all table names when true.
// Default is false.
SkipPrefix bool
}
StorageConfig holds all SQL storage configuration options that can be read from the configuration provider.
func LoadStorageConfig ¶
func LoadStorageConfig(cfg driver2.Config) (StorageConfig, error)
LoadStorageConfig reads all SQL storage options from cfg. It returns a zero-value StorageConfig (and nil error) when cfg is nil.
type TableNameCreator ¶
type TableNameCreator struct {
// contains filtered or unexported fields
}
func NewTableNameCreator ¶
func NewTableNameCreator(defaultPrefix string) *TableNameCreator
func (*TableNameCreator) CreateTableName ¶
func (c *TableNameCreator) CreateTableName(tablePrefix, name string, params ...string) (string, error)
func (*TableNameCreator) GetFormatter ¶
func (c *TableNameCreator) GetFormatter(prefix string) (*tableNameFormatter, error)
func (*TableNameCreator) MustGetTableName ¶
func (c *TableNameCreator) MustGetTableName(tablePrefix, name string, params ...string) string
type TableNames ¶
type TableNames struct {
Prefix string
Params []string
Movements string
Transactions string
Requests string
Validations string
TransactionEndorseAck string
Certifications string
Tokens string
Ownership string
PublicParams string
Wallets string
IdentityConfigurations string
IdentityInfo string
Signers string
TokenLocks string
KeyStore string
EIDLeases string
TokenSKICleanups string
}
func GetTableNames ¶
func GetTableNames(prefix string, params ...string) (TableNames, error)
GetTableNames returns the SQL table names for the given prefix and params using the default short codes. It is equivalent to calling GetTableNamesWithOverrides with a nil overrides map.
func GetTableNamesWithConfig ¶
func GetTableNamesWithConfig(prefix string, cfg StorageConfig, params ...string) (TableNames, error)
GetTableNamesWithConfig returns the SQL table names using all options from cfg.
func GetTableNamesWithOverrides ¶
func GetTableNamesWithOverrides(prefix string, overrides TableNamesConfig, params ...string) (TableNames, error)
GetTableNamesWithOverrides returns the SQL table names for the given prefix and params, applying any short-code substitutions from overrides before the FSC formatter wraps them with the prefix and params.
The overrides map key is the canonical short code (e.g. "id_signers") and the value is the replacement short code (e.g. "identity_signers"). Unknown keys produce a warning and are ignored; all other fields keep their default values.
func GetTableNamesWithOverridesSkipPrefix ¶
func GetTableNamesWithOverridesSkipPrefix(prefix string, overrides TableNamesConfig, params ...string) (TableNames, error)
GetTableNamesWithOverridesSkipPrefix is like GetTableNamesWithOverrides but omits the FSC-generated prefix from every table name.
type TableNamesConfig ¶
TableNamesConfig maps a short code (e.g. "id_signers") to the replacement short code that will be used when generating the final SQL table name. The FSC-generated prefix and params are still applied around the replacement value.
Unknown keys are warned and ignored. Omitted keys keep their default short codes.
func LoadTableNamesConfig ¶
func LoadTableNamesConfig(cfg driver2.Config) (TableNamesConfig, error)
LoadTableNamesConfig reads the table name overrides from cfg. It returns an empty map (and nil error) when cfg is nil or the config key is absent.
type TokenLockStore ¶
type TokenLockStore struct {
ReadDB *sql.DB
WriteDB *sql.DB
Table tokenLockTables
Logger logging.Logger
// contains filtered or unexported fields
}
func NewTokenLockStore ¶
func NewTokenLockStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter) (*TokenLockStore, error)
func (*TokenLockStore) Close ¶
func (db *TokenLockStore) Close() error
func (*TokenLockStore) CreateSchema ¶
func (db *TokenLockStore) CreateSchema() error
func (*TokenLockStore) GetSchema ¶
func (db *TokenLockStore) GetSchema() string
func (*TokenLockStore) Lock ¶
func (db *TokenLockStore) Lock(ctx context.Context, tokenID *token.ID, consumerTxID transaction.ID) error
func (*TokenLockStore) UnlockByTxID ¶
func (db *TokenLockStore) UnlockByTxID(ctx context.Context, consumerTxID transaction.ID) error
type TokenStore ¶
type TokenStore struct {
// contains filtered or unexported fields
}
func NewTokenStoreWithNotifier ¶
func NewTokenStoreWithNotifier(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, notifier driver.TokenNotifier) (*TokenStore, error)
func NewTokenStoreWithNotifierAndCleanup ¶
func NewTokenStoreWithNotifierAndCleanup( readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, notifier driver.TokenNotifier, cleanupLeaderFactory func(context.Context, *sql.DB, int64) (driver.CleanupLeadership, bool, error), ) (*TokenStore, error)
func (*TokenStore) AcquireCleanupLeadership ¶
func (db *TokenStore) AcquireCleanupLeadership(ctx context.Context, lockID int64) (driver.CleanupLeadership, bool, error)
AcquireCleanupLeadership attempts to acquire leadership for keystore cleanup operations. When no leader factory is configured, leadership is granted locally (for non-distributed deployments). In distributed deployments (PostgreSQL), this uses advisory locks to ensure only one instance performs cleanup. AcquireCleanupLeadership returns a leadership handle for cleanup sweeping. When no leader factory is configured, leadership is granted locally.
func (*TokenStore) Balance ¶
func (db *TokenStore) Balance(ctx context.Context, walletID string, typ token.Type) (*big.Int, error)
Balance returns the sum of the amounts of the tokens with type and EID equal to those passed as arguments. The result is returned as a *big.Int to support arbitrary precision and prevent overflow.
func (*TokenStore) Close ¶
func (db *TokenStore) Close() error
func (*TokenStore) ContinueTokenDBTransaction ¶
func (db *TokenStore) ContinueTokenDBTransaction(tx driver.Transaction) (driver.TokenStoreTransaction, error)
func (*TokenStore) CreateSchema ¶
func (db *TokenStore) CreateSchema() error
func (*TokenStore) DeleteTokens ¶
DeleteTokens deletes multiple tokens at the same time (when spent, invalid or expired)
func (*TokenStore) ExistsCertification ¶
func (*TokenStore) GetAllTokenInfos ¶
GetAllTokenInfos retrieves the token information for the passed ids.
func (*TokenStore) GetCertifications ¶
func (*TokenStore) GetDeletedTokensPendingSKICleanup ¶
func (db *TokenStore) GetDeletedTokensPendingSKICleanup(ctx context.Context, olderThan time.Duration, limit int) ([]driver.DeletedToken, error)
GetDeletedTokensPendingSKICleanup returns deleted tokens older than the specified duration that haven't had their SKI keys cleaned up yet (no record in token_ski_cleanups table).
func (*TokenStore) GetSchema ¶
func (db *TokenStore) GetSchema() string
func (*TokenStore) GetTokenMetadata ¶
GetTokenMetadata retrieves the token metadata for the passed ids. For each id, the callback is invoked to unmarshal the token metadata
func (*TokenStore) GetTokenOutputs ¶
func (db *TokenStore) GetTokenOutputs(ctx context.Context, ids []*token.ID, callback tdriver.QueryCallbackFunc) error
func (*TokenStore) GetTokenOutputsAndMeta ¶
func (db *TokenStore) GetTokenOutputsAndMeta(ctx context.Context, ids []*token.ID) ([][]byte, [][]byte, []token.Format, error)
GetTokenOutputsAndMeta retrieves both the token output, metadata, and type for the passed ids.
func (*TokenStore) GetTokens ¶
GetTokens returns the owned tokens and their identifier keys for the passed ids.
func (*TokenStore) HasTokenForIdentity ¶
func (db *TokenStore) HasTokenForIdentity(ctx context.Context, ownerIdentity []byte, ownerType string) (bool, error)
HasTokenForIdentity returns true if any token in the Tokens table has the given owner identity and owner type, regardless of whether the token has been spent or not.
func (*TokenStore) ListAuditTokens ¶
func (db *TokenStore) ListAuditTokens(ctx context.Context, ids ...*token.ID) ([]*token.Token, error)
ListAuditTokens returns the audited tokens associated to the passed ids
func (*TokenStore) ListHistoryIssuedTokens ¶
func (db *TokenStore) ListHistoryIssuedTokens(ctx context.Context) (*token.IssuedTokens, error)
ListHistoryIssuedTokens returns the list of issued tokens
func (*TokenStore) ListUnspentTokens ¶
func (db *TokenStore) ListUnspentTokens(ctx context.Context) (*token.UnspentTokens, error)
ListUnspentTokens returns the list of unspent tokens
func (*TokenStore) ListUnspentTokensBy ¶
func (db *TokenStore) ListUnspentTokensBy(ctx context.Context, walletID string, typ token.Type) (*token.UnspentTokens, error)
ListUnspentTokensBy returns the list of unspent tokens, filtered by owner and token type
func (*TokenStore) ListUnspentTokensByWallets ¶
func (db *TokenStore) ListUnspentTokensByWallets(ctx context.Context, walletIDs []string, typ token.Type) (map[string]*token.UnspentTokens, error)
ListUnspentTokensByWallets issues a single SELECT with an IN clause on the owning wallet, then partitions the result rows in Go. This avoids the N round-trip cost of calling ListUnspentTokensBy in a loop when a caller (e.g. a bank-node wallet list endpoint) needs balances for many wallets at once. Empty input returns an empty map without querying.
func (*TokenStore) MarkTokenCleaned ¶
func (db *TokenStore) MarkTokenCleaned(ctx context.Context, txID string, index uint64, cleanedBy string) error
MarkTokenCleaned marks a token as having its cryptographic keys cleaned up. This prevents the cleanup service from processing the same token multiple times. The cleanedBy parameter identifies which instance performed the cleanup.
func (*TokenStore) NewTokenDBTransaction ¶
func (db *TokenStore) NewTokenDBTransaction() (driver.TokenStoreTransaction, error)
func (*TokenStore) Notifier ¶
func (db *TokenStore) Notifier() (driver.TokenNotifier, error)
func (*TokenStore) PublicParams ¶
func (db *TokenStore) PublicParams(ctx context.Context) ([]byte, error)
func (*TokenStore) PublicParamsByHash ¶
func (*TokenStore) QueryTokenDetails ¶
func (db *TokenStore) QueryTokenDetails(ctx context.Context, params driver.QueryTokenDetailsParams) ([]driver.TokenDetails, error)
QueryTokenDetails returns details about owned tokens, regardless if they have been spent or not. Filters work cumulatively and may be left empty. If a token is owned by two enrollmentIDs and there is no filter on enrollmentID, the token will be returned twice (once for each owner).
func (*TokenStore) SetSupportedTokenFormats ¶
func (db *TokenStore) SetSupportedTokenFormats(formats []token.Format) error
func (*TokenStore) SpendableTokensIteratorBy ¶
func (db *TokenStore) SpendableTokensIteratorBy(ctx context.Context, walletID string, typ token.Type) (tdriver.SpendableTokensIterator, error)
SpendableTokensIteratorBy returns the minimum information about the tokens needed for the selector
func (*TokenStore) StoreCertifications ¶
func (*TokenStore) StorePublicParams ¶
func (db *TokenStore) StorePublicParams(ctx context.Context, raw []byte) error
func (*TokenStore) StoreToken ¶
func (db *TokenStore) StoreToken(ctx context.Context, tr driver.TokenRecord, owners []string) (err error)
func (*TokenStore) TransactionExists ¶
func (*TokenStore) UnspentLedgerTokensIteratorBy ¶
func (db *TokenStore) UnspentLedgerTokensIteratorBy(ctx context.Context) (tdriver.LedgerTokensIterator, error)
UnspentLedgerTokensIteratorBy returns an iterator over all unspent ledger tokens
func (*TokenStore) UnspentTokensIterator ¶
func (db *TokenStore) UnspentTokensIterator(ctx context.Context) (tdriver.UnspentTokensIterator, error)
UnspentTokensIterator returns an iterator over all unspent tokens
func (*TokenStore) UnspentTokensIteratorBy ¶
func (db *TokenStore) UnspentTokensIteratorBy(ctx context.Context, walletID string, tokenType token.Type) (tdriver.UnspentTokensIterator, error)
UnspentTokensIteratorBy returns an iterator of unspent tokens owned by the passed wallet id and of the passed type. Empty tokenType returns all types.
Implemented as a single SQL with two UNION ALL branches so each side can use its own index, instead of a cross-table OR predicate that PostgreSQL cannot resolve with the partial index on (owner_wallet_id, token_type) WHERE is_deleted=false AND owner=true:
- tokens directly owned: filters tokens.owner_wallet_id, hits the partial index in microseconds. Joins ownership by primary key to preserve the pre-PR semantic that a token must have at least one ownership row to be visible (StoreToken can persist a tokens row without an ownership row when the owners slice is empty, and the original INNER JOIN intentionally excluded those).
- tokens reachable via the ownership-delegation table: joins ownership -> tokens by primary key. Returns zero rows when delegation is not configured, at which point that branch is essentially free.
Both branches share a single SQL statement and therefore a single connection from the pool, which avoids the deadlock that would arise if two concurrent QueryContexts each tried to acquire a second connection. PostgreSQL 9.6+ may also execute the branches in parallel via parallel append. UNION ALL is used (not UNION) to skip the per-row sort/hash dedup pass; duplicates between the two branches (and within branch 1 when a token has multiple ownership rows) are filtered at the iterator layer.
func (*TokenStore) UnsupportedTokensIteratorBy ¶
func (db *TokenStore) UnsupportedTokensIteratorBy(ctx context.Context, walletID string, tokenType token.Type) (tdriver.UnsupportedTokensIterator, error)
UnsupportedTokensIteratorBy returns the minimum information for upgrade about the tokens that are not supported
func (*TokenStore) WhoDeletedTokens ¶
func (db *TokenStore) WhoDeletedTokens(ctx context.Context, inputs ...*token.ID) ([]string, []bool, error)
WhoDeletedTokens returns information about which transaction deleted the passed tokens. The bool array is an indicator used to tell if the token at a given position has been deleted or not
type TokenTransaction ¶
type TokenTransaction struct {
// contains filtered or unexported fields
}
func (*TokenTransaction) Commit ¶
func (t *TokenTransaction) Commit() error
func (*TokenTransaction) Rollback ¶
func (t *TokenTransaction) Rollback() error
func (*TokenTransaction) SetSpendable ¶
func (*TokenTransaction) SetSpendableBySupportedTokenFormats ¶
func (*TokenTransaction) StoreToken ¶
func (t *TokenTransaction) StoreToken(ctx context.Context, tr driver.TokenRecord, owners []string) error
type TransactionStore ¶
type TransactionStore struct {
// contains filtered or unexported fields
}
func NewAuditTransactionStore ¶
func NewAuditTransactionStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, pi common3.PagInterpreter) (*TransactionStore, error)
func NewOwnerTransactionStore ¶
func NewOwnerTransactionStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, pi common3.PagInterpreter) (*TransactionStore, error)
func NewTransactionStoreWithNotifierAndRecovery ¶
func NewTransactionStoreWithNotifierAndRecovery( readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, pi common3.PagInterpreter, notifier dbdriver.TransactionNotifier, recoveryLeaderFactory func(context.Context, *sql.DB, int64) (dbdriver.RecoveryLeadership, bool, error), ) (*TransactionStore, error)
func (*TransactionStore) AcquireRecoveryLeadership ¶
func (db *TransactionStore) AcquireRecoveryLeadership(ctx context.Context, lockID int64) (dbdriver.RecoveryLeadership, bool, error)
AcquireRecoveryLeadership returns a leadership handle for recovery sweeping. When no leader factory is configured, leadership is granted locally.
func (*TransactionStore) AddTransactionEndorsementAck ¶
func (*TransactionStore) ClaimPendingTransactions ¶
func (db *TransactionStore) ClaimPendingTransactions(ctx context.Context, params dbdriver.RecoveryClaimParams) ([]*dbdriver.RecoveryClaim, error)
ClaimPendingTransactions returns a claimed batch of Pending transactions. The default SQL implementation is permissive and does not persist recovery claims. tx_id and stored_at are projected directly from the requests table — the transactions table is no longer joined since it carries no information the recovery loop needs and adding it would re-introduce a fan-out by movement/output that the caller would have to dedupe by tx_id.
func (*TransactionStore) Close ¶
func (db *TransactionStore) Close() error
func (*TransactionStore) CreateSchema ¶
func (db *TransactionStore) CreateSchema() error
func (*TransactionStore) GetSchema ¶
func (db *TransactionStore) GetSchema() string
func (*TransactionStore) GetTokenRequest ¶
func (*TransactionStore) GetTokenRequests ¶
func (db *TransactionStore) GetTokenRequests(ctx context.Context, txIDs []string) (map[string][]byte, error)
GetTokenRequests fetches the token requests for the given tx ids in a single SELECT. Missing tx ids are absent from the returned map — callers should treat a missing key identically to GetTokenRequest returning nil. Empty input returns an empty map without querying.
func (*TransactionStore) GetTransactionEndorsementAcks ¶
func (*TransactionStore) NewTransactionStoreTransaction ¶
func (db *TransactionStore) NewTransactionStoreTransaction() (dbdriver.TransactionStoreTransaction, error)
func (*TransactionStore) Notifier ¶
func (db *TransactionStore) Notifier() (dbdriver.TransactionNotifier, error)
func (*TransactionStore) PrefixedTableName ¶
func (s *TransactionStore) PrefixedTableName(name string) string
PrefixedTableName returns the formatted table name for the given logical name.
func (*TransactionStore) QueryMovements ¶
func (db *TransactionStore) QueryMovements(ctx context.Context, params dbdriver.QueryMovementsParams) (res []*dbdriver.MovementRecord, err error)
func (*TransactionStore) QueryTokenRequests ¶
func (db *TransactionStore) QueryTokenRequests(ctx context.Context, params dbdriver.QueryTokenRequestsParams) (dbdriver.TokenRequestIterator, error)
QueryTokenRequests returns an iterator over the token requests matching the passed params
func (*TransactionStore) QueryTransactions ¶
func (db *TransactionStore) QueryTransactions(ctx context.Context, params dbdriver.QueryTransactionsParams, pagination driver3.Pagination) (*driver3.PageIterator[*dbdriver.TransactionRecord], error)
func (*TransactionStore) ReleaseRecoveryClaim ¶
ReleaseRecoveryClaim clears persisted recovery claim metadata and stores the recovery message. The default SQL implementation is a no-op.
type TransactionStoreTransaction ¶
type TransactionStoreTransaction struct {
// contains filtered or unexported fields
}
func (*TransactionStoreTransaction) AddMovement ¶
func (w *TransactionStoreTransaction) AddMovement(ctx context.Context, rs ...dbdriver.MovementRecord) error
func (*TransactionStoreTransaction) AddTokenRequest ¶
func (*TransactionStoreTransaction) AddTransaction ¶
func (w *TransactionStoreTransaction) AddTransaction(ctx context.Context, rs ...dbdriver.TransactionRecord) error
func (*TransactionStoreTransaction) Commit ¶
func (w *TransactionStoreTransaction) Commit() error
func (*TransactionStoreTransaction) Impl ¶
func (w *TransactionStoreTransaction) Impl() dbdriver.TransactionImpl
func (*TransactionStoreTransaction) Rollback ¶
func (w *TransactionStoreTransaction) Rollback()
type WalletStore ¶
type WalletStore struct {
// contains filtered or unexported fields
}
func NewWalletStore ¶
func NewWalletStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter) (*WalletStore, error)
func (*WalletStore) Close ¶
func (db *WalletStore) Close() error
func (*WalletStore) CreateSchema ¶
func (db *WalletStore) CreateSchema() error
func (*WalletStore) GetSchema ¶
func (db *WalletStore) GetSchema() string