common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SelectStatement         = `SELECT`
	SelectDistinctStatement = `SELECT DISTINCT`
	InsertStatement         = `INSERT INTO`
	UpdateStatement         = `UPDATE`
	DeleteStatement         = `DELETE FROM`
)

Variables

This section is empty.

Functions

func Close

func Close(closer Closer)

func HasMovementsParams added in v0.5.0

func HasMovementsParams(params driver.QueryMovementsParams) cond.Condition

func HasTokenDetails added in v0.5.0

func HasTokenDetails(params driver.QueryTokenDetailsParams, tokenTable common.Table) cond.Condition

func HasTokens added in v0.5.0

func HasTokens(colTxID, colIdx common.FieldName, ids ...*token.ID) cond.Condition

func HasTransactionParams added in v0.5.0

func HasTransactionParams(params driver.QueryTransactionsParams, table common.Table) cond.Condition

func HasValidationParams added in v0.5.0

func HasValidationParams(params driver.QueryValidationRecordsParams) cond.Condition

func IsExpiredToken added in v0.5.0

func IsExpiredToken(tokenRequests, tokenLocks common3.Table, leaseExpiry time.Duration) cond.Condition

func TestAWAddMovement added in v0.5.0

func TestAWAddMovement(t *testing.T, store transactionsStoreConstructor)

func TestAWAddTokenRequest added in v0.5.0

func TestAWAddTokenRequest(t *testing.T, store transactionsStoreConstructor)

func TestAWAddTransaction added in v0.5.0

func TestAWAddTransaction(t *testing.T, store transactionsStoreConstructor)

func TestAWAddValidationRecord added in v0.5.0

func TestAWAddValidationRecord(t *testing.T, store transactionsStoreConstructor)

func TestAddTransactionEndorsementAck added in v0.5.0

func TestAddTransactionEndorsementAck(t *testing.T, store transactionsStoreConstructor)

func TestGetStatus added in v0.5.0

func TestGetStatus(t *testing.T, store transactionsStoreConstructor)

func TestGetTokenRequest added in v0.5.0

func TestGetTokenRequest(t *testing.T, store transactionsStoreConstructor)

func TestGetTransactionEndorsementAcks added in v0.5.0

func TestGetTransactionEndorsementAcks(t *testing.T, store transactionsStoreConstructor)

func TestGetWalletID added in v0.5.0

func TestGetWalletID(t *testing.T, store walletStoreConstructor)

func TestGetWalletIDs added in v0.5.0

func TestGetWalletIDs(t *testing.T, store walletStoreConstructor)

func TestIdentityExists added in v0.5.0

func TestIdentityExists(t *testing.T, store walletStoreConstructor)

func TestLoadMeta added in v0.5.0

func TestLoadMeta(t *testing.T, store walletStoreConstructor)

func TestLock added in v0.5.0

func TestLock(t *testing.T, store tokenLockStoreConstructor)

func TestQueryMovements added in v0.5.0

func TestQueryMovements(t *testing.T, store transactionsStoreConstructor, traits QueryConstructorTraits)

func TestQueryTokenRequests added in v0.5.0

func TestQueryTokenRequests(t *testing.T, store transactionsStoreConstructor, traits QueryConstructorTraits)

func TestQueryTransactions added in v0.5.0

func TestQueryTransactions(t *testing.T, store transactionsStoreConstructor)

func TestQueryValidations added in v0.5.0

func TestQueryValidations(t *testing.T, store transactionsStoreConstructor, traits QueryConstructorTraits)

func TestSetStatus added in v0.5.0

func TestSetStatus(t *testing.T, store transactionsStoreConstructor)

func TestStoreIdentity added in v0.5.0

func TestStoreIdentity(t *testing.T, store walletStoreConstructor)

func TestUnlockByTxID added in v0.5.0

func TestUnlockByTxID(t *testing.T, store tokenLockStoreConstructor)

Types

type AnyUUID added in v0.5.0

type AnyUUID struct{}

func (AnyUUID) Match added in v0.5.0

func (a AnyUUID) Match(v driver2.Value) bool

type AtomicWrite

type AtomicWrite struct {
	// contains filtered or unexported fields
}

func (*AtomicWrite) AddMovement

func (w *AtomicWrite) AddMovement(ctx context.Context, rs ...driver.MovementRecord) error

func (*AtomicWrite) AddTokenRequest

func (w *AtomicWrite) AddTokenRequest(ctx context.Context, txID string, tr []byte, applicationMetadata, publicMetadata map[string][]byte, ppHash driver2.PPHash) error

func (*AtomicWrite) AddTransaction

func (w *AtomicWrite) AddTransaction(ctx context.Context, rs ...driver.TransactionRecord) error

func (*AtomicWrite) AddValidationRecord

func (w *AtomicWrite) AddValidationRecord(ctx context.Context, txID string, meta map[string][]byte) error

func (*AtomicWrite) Commit

func (w *AtomicWrite) Commit() error

func (*AtomicWrite) Rollback

func (w *AtomicWrite) Rollback()

type Closer

type Closer interface {
	Close() error
}

type Delete

type Delete struct {
	// contains filtered or unexported fields
}

func NewDeleteFrom

func NewDeleteFrom(table string) *Delete

func (*Delete) Compile

func (s *Delete) Compile() (string, error)

func (*Delete) Where

func (s *Delete) Where(where string) *Delete

type IdentityConfigurationIterator

type IdentityConfigurationIterator struct {
	// contains filtered or unexported fields
}

func (*IdentityConfigurationIterator) Close

func (*IdentityConfigurationIterator) HasNext

func (w *IdentityConfigurationIterator) HasNext() bool

func (*IdentityConfigurationIterator) Next

type IdentityStore added in v0.5.0

type IdentityStore struct {
	// contains filtered or unexported fields
}

func NewCachedIdentityStore added in v0.5.0

func NewCachedIdentityStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter) (*IdentityStore, error)

func NewIdentityStore added in v0.5.0

func NewIdentityStore(readDB, writeDB *sql.DB, tables TableNames, signerInfoCache cache[bool], auditInfoCache cache[[]byte], ci common3.CondInterpreter) (*IdentityStore, error)

func (*IdentityStore) AddConfiguration added in v0.5.0

func (db *IdentityStore) AddConfiguration(ctx context.Context, wp driver.IdentityConfiguration) error

func (*IdentityStore) Close added in v0.5.0

func (db *IdentityStore) Close() error

func (*IdentityStore) ConfigurationExists added in v0.5.0

func (db *IdentityStore) ConfigurationExists(ctx context.Context, id, typ, url string) (bool, error)

func (*IdentityStore) CreateSchema added in v0.5.0

func (db *IdentityStore) CreateSchema() error

func (*IdentityStore) GetAuditInfo added in v0.5.0

func (db *IdentityStore) GetAuditInfo(ctx context.Context, id []byte) ([]byte, error)

func (*IdentityStore) GetExistingSignerInfo added in v0.5.0

func (db *IdentityStore) GetExistingSignerInfo(ctx context.Context, ids ...tdriver.Identity) ([]string, error)

func (*IdentityStore) GetSchema added in v0.5.0

func (db *IdentityStore) GetSchema() string

func (*IdentityStore) GetSignerInfo added in v0.5.0

func (db *IdentityStore) GetSignerInfo(ctx context.Context, identity []byte) ([]byte, error)

func (*IdentityStore) GetTokenInfo added in v0.5.0

func (db *IdentityStore) GetTokenInfo(ctx context.Context, id []byte) ([]byte, []byte, error)

func (*IdentityStore) IteratorConfigurations added in v0.5.0

func (db *IdentityStore) IteratorConfigurations(ctx context.Context, configurationType string) (driver3.IdentityConfigurationIterator, error)

func (*IdentityStore) SignerInfoExists added in v0.5.0

func (db *IdentityStore) SignerInfoExists(ctx context.Context, id []byte) (bool, error)

func (*IdentityStore) StoreIdentityData added in v0.5.0

func (db *IdentityStore) StoreIdentityData(ctx context.Context, id []byte, identityAudit []byte, tokenMetadata []byte, tokenMetadataAudit []byte) error

func (*IdentityStore) StoreSignerInfo added in v0.5.0

func (db *IdentityStore) StoreSignerInfo(ctx context.Context, id, info []byte) error

type Insert

type Insert struct {
	// contains filtered or unexported fields
}

func NewInsertInto

func NewInsertInto(table string) *Insert

func (*Insert) Compile

func (i *Insert) Compile() (string, error)

func (*Insert) Rows

func (i *Insert) Rows(rows string) *Insert

type PersistenceConstructor added in v0.5.0

type PersistenceConstructor[V common.DBObject] func(*common.RWDB, TableNames) (V, error)

type QueryConstructorTraits added in v0.5.0

type QueryConstructorTraits struct {
	SupportsIN          bool
	MultipleParenthesis bool
}

type Select

type Select struct {
	// contains filtered or unexported fields
}

func NewSelect

func NewSelect(columns ...string) *Select

func NewSelectDistinct

func NewSelectDistinct(columns ...string) *Select

func (*Select) Compile

func (s *Select) Compile() (string, error)

func (*Select) From

func (s *Select) From(tables ...string) *Select

func (*Select) OrderBy

func (s *Select) OrderBy(orderBy string) *Select

func (*Select) Where

func (s *Select) Where(where string) *Select

type TableNames added in v0.5.0

type TableNames struct {
	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
}

func GetTableNames

func GetTableNames(prefix string, params ...string) (TableNames, error)

type TokenLockStore added in v0.5.0

type TokenLockStore struct {
	ReadDB  *sql.DB
	WriteDB *sql.DB
	Table   tokenLockTables
	Logger  logging.Logger
	// contains filtered or unexported fields
}

func NewTokenLockStore added in v0.5.0

func NewTokenLockStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter) (*TokenLockStore, error)

func (*TokenLockStore) Close added in v0.5.0

func (db *TokenLockStore) Close() error

func (*TokenLockStore) CreateSchema added in v0.5.0

func (db *TokenLockStore) CreateSchema() error

func (*TokenLockStore) GetSchema added in v0.5.0

func (db *TokenLockStore) GetSchema() string

func (*TokenLockStore) Lock added in v0.5.0

func (db *TokenLockStore) Lock(ctx context.Context, tokenID *token.ID, consumerTxID transaction.ID) error

func (*TokenLockStore) UnlockByTxID added in v0.5.0

func (db *TokenLockStore) UnlockByTxID(ctx context.Context, consumerTxID transaction.ID) error

type TokenStore added in v0.5.0

type TokenStore struct {
	// contains filtered or unexported fields
}

func NewTokenStore added in v0.5.0

func NewTokenStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter) (*TokenStore, error)

func (*TokenStore) Balance added in v0.5.0

func (db *TokenStore) Balance(ctx context.Context, walletID string, typ token.Type) (uint64, error)

Balance returns the sun of the amounts, with 64 bits of precision, of the tokens with type and EID equal to those passed as arguments.

func (*TokenStore) Close added in v0.5.0

func (db *TokenStore) Close() error

func (*TokenStore) CreateSchema added in v0.5.0

func (db *TokenStore) CreateSchema() error

func (*TokenStore) DeleteTokens added in v0.5.0

func (db *TokenStore) DeleteTokens(ctx context.Context, deletedBy string, ids ...*token.ID) error

DeleteTokens deletes multiple tokens at the same time (when spent, invalid or expired)

func (*TokenStore) ExistsCertification added in v0.5.0

func (db *TokenStore) ExistsCertification(ctx context.Context, tokenID *token.ID) bool

func (*TokenStore) GetAllTokenInfos added in v0.5.0

func (db *TokenStore) GetAllTokenInfos(ctx context.Context, ids []*token.ID) ([][]byte, error)

GetAllTokenInfos retrieves the token information for the passed ids.

func (*TokenStore) GetCertifications added in v0.5.0

func (db *TokenStore) GetCertifications(ctx context.Context, ids []*token.ID) ([][]byte, error)

func (*TokenStore) GetSchema added in v0.5.0

func (db *TokenStore) GetSchema() string

func (*TokenStore) GetTokenMetadata added in v0.5.0

func (db *TokenStore) GetTokenMetadata(ctx context.Context, ids []*token.ID) ([][]byte, error)

GetTokenMetadata retrieves the token metadata for the passed ids. For each id, the callback is invoked to unmarshal the token metadata

func (*TokenStore) GetTokenOutputs added in v0.5.0

func (db *TokenStore) GetTokenOutputs(ctx context.Context, ids []*token.ID, callback tdriver.QueryCallbackFunc) error

func (*TokenStore) GetTokenOutputsAndMeta added in v0.5.0

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 added in v0.5.0

func (db *TokenStore) GetTokens(ctx context.Context, inputs ...*token.ID) ([]*token.Token, error)

GetTokens returns the owned tokens and their identifier keys for the passed ids.

func (*TokenStore) IsMine added in v0.5.0

func (db *TokenStore) IsMine(ctx context.Context, txID string, index uint64) (bool, error)

IsMine just checks if the token is in the local storage and not deleted

func (*TokenStore) ListAuditTokens added in v0.5.0

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 added in v0.5.0

func (db *TokenStore) ListHistoryIssuedTokens(ctx context.Context) (*token.IssuedTokens, error)

ListHistoryIssuedTokens returns the list of issued tokens

func (*TokenStore) ListUnspentTokens added in v0.5.0

func (db *TokenStore) ListUnspentTokens(ctx context.Context) (*token.UnspentTokens, error)

ListUnspentTokens returns the list of unspent tokens

func (*TokenStore) ListUnspentTokensBy added in v0.5.0

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) NewTokenDBTransaction added in v0.5.0

func (db *TokenStore) NewTokenDBTransaction() (driver.TokenStoreTransaction, error)

func (*TokenStore) PublicParams added in v0.5.0

func (db *TokenStore) PublicParams(ctx context.Context) ([]byte, error)

func (*TokenStore) PublicParamsByHash added in v0.5.0

func (db *TokenStore) PublicParamsByHash(ctx context.Context, rawHash tdriver.PPHash) ([]byte, error)

func (*TokenStore) QueryTokenDetails added in v0.5.0

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 added in v0.5.0

func (db *TokenStore) SetSupportedTokenFormats(formats []token.Format) error

func (*TokenStore) SpendableTokensIteratorBy added in v0.5.0

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 added in v0.5.0

func (db *TokenStore) StoreCertifications(ctx context.Context, certifications map[*token.ID][]byte) error

func (*TokenStore) StorePublicParams added in v0.5.0

func (db *TokenStore) StorePublicParams(ctx context.Context, raw []byte) error

func (*TokenStore) StoreToken added in v0.5.0

func (db *TokenStore) StoreToken(ctx context.Context, tr driver.TokenRecord, owners []string) (err error)

func (*TokenStore) TransactionExists added in v0.5.0

func (db *TokenStore) TransactionExists(ctx context.Context, id string) (bool, error)

func (*TokenStore) UnspentLedgerTokensIteratorBy added in v0.5.0

func (db *TokenStore) UnspentLedgerTokensIteratorBy(ctx context.Context) (tdriver.LedgerTokensIterator, error)

UnspentLedgerTokensIteratorBy returns an iterator over all unspent ledger tokens

func (*TokenStore) UnspentTokensIterator added in v0.5.0

func (db *TokenStore) UnspentTokensIterator(ctx context.Context) (tdriver.UnspentTokensIterator, error)

UnspentTokensIterator returns an iterator over all unspent tokens

func (*TokenStore) UnspentTokensIteratorBy added in v0.5.0

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 id and whose type is the passed on. The token type can be empty. In that case, tokens of any type are returned.

func (*TokenStore) UnsupportedTokensIteratorBy added in v0.5.0

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 added in v0.5.0

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

func (t *TokenTransaction) Delete(ctx context.Context, tokenID token.ID, deletedBy string) error

func (*TokenTransaction) GetToken

func (t *TokenTransaction) GetToken(ctx context.Context, tokenID token.ID, includeDeleted bool) (*token.Token, []string, error)

func (*TokenTransaction) Rollback

func (t *TokenTransaction) Rollback() error

func (*TokenTransaction) SetSpendable

func (t *TokenTransaction) SetSpendable(ctx context.Context, tokenID token.ID, spendable bool) error

func (*TokenTransaction) SetSpendableBySupportedTokenFormats

func (t *TokenTransaction) SetSpendableBySupportedTokenFormats(ctx context.Context, formats []token.Format) error

func (*TokenTransaction) StoreToken

func (t *TokenTransaction) StoreToken(ctx context.Context, tr driver.TokenRecord, owners []string) error

type TransactionStore added in v0.5.0

type TransactionStore struct {
	// contains filtered or unexported fields
}

func NewAuditTransactionStore added in v0.5.0

func NewAuditTransactionStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, pi common3.PagInterpreter) (*TransactionStore, error)

func NewOwnerTransactionStore added in v0.5.0

func NewOwnerTransactionStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter, pi common3.PagInterpreter) (*TransactionStore, error)

func (*TransactionStore) AddTransactionEndorsementAck added in v0.5.0

func (db *TransactionStore) AddTransactionEndorsementAck(ctx context.Context, txID string, endorser token.Identity, sigma []byte) (err error)

func (*TransactionStore) BeginAtomicWrite added in v0.5.0

func (db *TransactionStore) BeginAtomicWrite() (driver.AtomicWrite, error)

func (*TransactionStore) Close added in v0.5.0

func (db *TransactionStore) Close() error

func (*TransactionStore) CreateSchema added in v0.5.0

func (db *TransactionStore) CreateSchema() error

func (*TransactionStore) GetSchema added in v0.5.0

func (db *TransactionStore) GetSchema() string

func (*TransactionStore) GetStatus added in v0.5.0

func (db *TransactionStore) GetStatus(ctx context.Context, txID string) (driver.TxStatus, string, error)

func (*TransactionStore) GetTokenRequest added in v0.5.0

func (db *TransactionStore) GetTokenRequest(ctx context.Context, txID string) ([]byte, error)

func (*TransactionStore) GetTransactionEndorsementAcks added in v0.5.0

func (db *TransactionStore) GetTransactionEndorsementAcks(ctx context.Context, txID string) (map[string][]byte, error)

func (*TransactionStore) QueryMovements added in v0.5.0

func (db *TransactionStore) QueryMovements(ctx context.Context, params driver.QueryMovementsParams) (res []*driver.MovementRecord, err error)

func (*TransactionStore) QueryTokenRequests added in v0.5.0

QueryTokenRequests returns an iterator over the token requests matching the passed params

func (*TransactionStore) QueryTransactions added in v0.5.0

func (*TransactionStore) QueryValidations added in v0.5.0

func (*TransactionStore) SetStatus added in v0.5.0

func (db *TransactionStore) SetStatus(ctx context.Context, txID string, status driver.TxStatus, message string) error

type Update

type Update struct {
	// contains filtered or unexported fields
}

func NewUpdate

func NewUpdate(table string) *Update

func (*Update) Compile

func (u *Update) Compile() (string, error)

func (*Update) Set

func (u *Update) Set(rows string) *Update

func (*Update) Where

func (u *Update) Where(where string) *Update

type WalletStore added in v0.5.0

type WalletStore struct {
	// contains filtered or unexported fields
}

func NewWalletStore added in v0.5.0

func NewWalletStore(readDB, writeDB *sql.DB, tables TableNames, ci common3.CondInterpreter) (*WalletStore, error)

func (*WalletStore) Close added in v0.5.0

func (db *WalletStore) Close() error

func (*WalletStore) CreateSchema added in v0.5.0

func (db *WalletStore) CreateSchema() error

func (*WalletStore) GetSchema added in v0.5.0

func (db *WalletStore) GetSchema() string

func (*WalletStore) GetWalletID added in v0.5.0

func (db *WalletStore) GetWalletID(ctx context.Context, identity token.Identity, roleID int) (driver.WalletID, error)

func (*WalletStore) GetWalletIDs added in v0.5.0

func (db *WalletStore) GetWalletIDs(ctx context.Context, roleID int) ([]driver.WalletID, error)

func (*WalletStore) IdentityExists added in v0.5.0

func (db *WalletStore) IdentityExists(ctx context.Context, identity token.Identity, wID driver.WalletID, roleID int) bool

func (*WalletStore) LoadMeta added in v0.5.0

func (db *WalletStore) LoadMeta(ctx context.Context, identity token.Identity, wID driver.WalletID, roleID int) ([]byte, error)

func (*WalletStore) StoreIdentity added in v0.5.0

func (db *WalletStore) StoreIdentity(ctx context.Context, identity token.Identity, eID string, wID driver.WalletID, roleID int, meta []byte) error

Jump to

Keyboard shortcuts

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