Documentation
¶
Index ¶
- func NewStore(db *bun.DB) *pgStore
- type InstrumentedStore
- func (s *InstrumentedStore) AddToWhitelist(ctx context.Context, evmAddress, note string) error
- func (s *InstrumentedStore) CreateUser(ctx context.Context, usr *user.User) error
- func (s *InstrumentedStore) DeleteUser(ctx context.Context, evmAddress string) error
- func (s *InstrumentedStore) GetUserByCantonPartyID(ctx context.Context, partyID string) (*user.User, error)
- func (s *InstrumentedStore) GetUserByEVMAddress(ctx context.Context, evmAddress string) (*user.User, error)
- func (s *InstrumentedStore) GetUserByFingerprint(ctx context.Context, fingerprint string) (*user.User, error)
- func (s *InstrumentedStore) GetUserKeyByCantonPartyID(ctx context.Context, decryptor KeyDecryptor, partyID string) ([]byte, error)
- func (s *InstrumentedStore) GetUserKeyByEVMAddress(ctx context.Context, decryptor KeyDecryptor, evmAddress string) ([]byte, error)
- func (s *InstrumentedStore) GetUserKeyByFingerprint(ctx context.Context, decryptor KeyDecryptor, fingerprint string) ([]byte, error)
- func (s *InstrumentedStore) IsWhitelisted(ctx context.Context, evmAddress string) (bool, error)
- func (s *InstrumentedStore) ListCustodialUsers(ctx context.Context) ([]*user.User, error)
- func (s *InstrumentedStore) ListUsers(ctx context.Context) ([]*user.User, error)
- func (s *InstrumentedStore) UserExists(ctx context.Context, evmAddress string) (bool, error)
- type KeyDecryptor
- type Store
- type StoreMetrics
- type StoreOperation
- type UserDao
- type WhitelistDao
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InstrumentedStore ¶
type InstrumentedStore struct {
// contains filtered or unexported fields
}
InstrumentedStore wraps a Store and records Prometheus metrics for every database operation.
func NewInstrumentedStore ¶
func NewInstrumentedStore(inner Store, metrics *StoreMetrics) *InstrumentedStore
NewInstrumentedStore returns a metrics-instrumented wrapper around the given Store.
func (*InstrumentedStore) AddToWhitelist ¶
func (s *InstrumentedStore) AddToWhitelist(ctx context.Context, evmAddress, note string) error
func (*InstrumentedStore) CreateUser ¶
func (*InstrumentedStore) DeleteUser ¶
func (s *InstrumentedStore) DeleteUser(ctx context.Context, evmAddress string) error
func (*InstrumentedStore) GetUserByCantonPartyID ¶
func (*InstrumentedStore) GetUserByEVMAddress ¶
func (*InstrumentedStore) GetUserByFingerprint ¶
func (*InstrumentedStore) GetUserKeyByCantonPartyID ¶
func (s *InstrumentedStore) GetUserKeyByCantonPartyID( ctx context.Context, decryptor KeyDecryptor, partyID string, ) ([]byte, error)
func (*InstrumentedStore) GetUserKeyByEVMAddress ¶
func (s *InstrumentedStore) GetUserKeyByEVMAddress( ctx context.Context, decryptor KeyDecryptor, evmAddress string, ) ([]byte, error)
func (*InstrumentedStore) GetUserKeyByFingerprint ¶
func (s *InstrumentedStore) GetUserKeyByFingerprint( ctx context.Context, decryptor KeyDecryptor, fingerprint string, ) ([]byte, error)
func (*InstrumentedStore) IsWhitelisted ¶
func (*InstrumentedStore) ListCustodialUsers ¶
func (*InstrumentedStore) UserExists ¶
type KeyDecryptor ¶
KeyDecryptor decrypts an encrypted private key string into raw bytes.
type Store ¶
type Store interface {
CreateUser(ctx context.Context, usr *user.User) error
GetUserByEVMAddress(ctx context.Context, evmAddress string) (*user.User, error)
GetUserByCantonPartyID(ctx context.Context, partyID string) (*user.User, error)
GetUserByFingerprint(ctx context.Context, fingerprint string) (*user.User, error)
UserExists(ctx context.Context, evmAddress string) (bool, error)
DeleteUser(ctx context.Context, evmAddress string) error
ListUsers(ctx context.Context) ([]*user.User, error)
ListCustodialUsers(ctx context.Context) ([]*user.User, error)
IsWhitelisted(ctx context.Context, evmAddress string) (bool, error)
AddToWhitelist(ctx context.Context, evmAddress, note string) error
GetUserKeyByCantonPartyID(ctx context.Context, decryptor KeyDecryptor, partyID string) ([]byte, error)
GetUserKeyByEVMAddress(ctx context.Context, decryptor KeyDecryptor, evmAddress string) ([]byte, error)
GetUserKeyByFingerprint(ctx context.Context, decryptor KeyDecryptor, fingerprint string) ([]byte, error)
}
Store is the full interface for user persistence. Consumers should define narrower interfaces for the methods they need.
type StoreMetrics ¶
type StoreMetrics struct {
// QueryDuration tracks database query latency partitioned by operation.
QueryDuration *prometheus.HistogramVec
// Errors counts database errors partitioned by operation.
Errors *prometheus.CounterVec
}
StoreMetrics holds Prometheus collectors for the user store database layer.
func NewStoreMetrics ¶
func NewStoreMetrics(reg sharedmetrics.NamespacedRegisterer) *StoreMetrics
NewStoreMetrics registers user store metrics against the given registerer.
func (*StoreMetrics) IncErrors ¶
func (m *StoreMetrics) IncErrors(op StoreOperation)
IncErrors increments the error counter for the given operation.
func (*StoreMetrics) ObserveQueryDuration ¶
func (m *StoreMetrics) ObserveQueryDuration(op StoreOperation) prometheus.Observer
ObserveQueryDuration returns the observer for the given operation.
type StoreOperation ¶
type StoreOperation string
StoreOperation identifies a database operation for metrics labeling.
const ( OpCreateUser StoreOperation = "create_user" OpGetUserByEVMAddress StoreOperation = "get_user_by_evm_address" OpGetUserByCantonPartyID StoreOperation = "get_user_by_canton_party_id" OpGetUserByFingerprint StoreOperation = "get_user_by_fingerprint" OpUserExists StoreOperation = "user_exists" OpDeleteUser StoreOperation = "delete_user" OpListUsers StoreOperation = "list_users" OpListCustodialUsers StoreOperation = "list_custodial_users" OpIsWhitelisted StoreOperation = "is_whitelisted" OpAddToWhitelist StoreOperation = "add_to_whitelist" OpGetKeyByCantonPartyID StoreOperation = "get_key_by_canton_party_id" OpGetKeyByEVMAddress StoreOperation = "get_key_by_evm_address" OpGetKeyByFingerprint StoreOperation = "get_key_by_fingerprint" )
type UserDao ¶
type UserDao struct {
bun.BaseModel `bun:"table:users,alias:u"`
ID int64 `bun:"id,pk,autoincrement"`
EVMAddress string `bun:"evm_address,unique,notnull,type:varchar(42)"`
CantonParty string `bun:"canton_party,notnull,type:varchar(255)"`
Fingerprint string `bun:"fingerprint,notnull,type:varchar(128)"`
MappingCID *string `bun:"mapping_cid,type:varchar(255)"`
CreatedAt time.Time `bun:"created_at,nullzero,default:current_timestamp"`
CantonPartyID *string `bun:"canton_party_id,type:varchar(255)"`
CantonPrivateKeyEncrypted *string `bun:"canton_private_key_encrypted,type:text"`
CantonKeyCreatedAt *time.Time `bun:"canton_key_created_at"`
KeyMode string `bun:"key_mode,notnull,default:'custodial',type:varchar(20)"`
CantonPublicKeyFingerprint *string `bun:"canton_public_key_fingerprint,type:text"`
}
UserDao is a data access object that maps directly to the 'users' table in PostgreSQL.
type WhitelistDao ¶
type WhitelistDao struct {
bun.BaseModel `bun:"table:whitelist,alias:w"`
EVMAddress string `bun:"evm_address,pk,type:varchar(42)"`
Note *string `bun:"note,type:varchar(500)"`
CreatedAt time.Time `bun:"created_at,nullzero,default:current_timestamp"`
}
WhitelistDao is a data access object that maps directly to the 'whitelist' table in PostgreSQL.