database

package
v0.0.0-...-8351e0c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: ISC Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBManager

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

DBManager handles database operations

func NewDBManager

func NewDBManager(appRoot string) (*DBManager, error)

NewDBManager creates a new database manager

func (*DBManager) CheckAndDeductBalance

func (db *DBManager) CheckAndDeductBalance(uid []byte, costAtoms int64, debug bool) (bool, error)

CheckAndDeductBalance checks if a user has sufficient balance and deducts the cost if they do. costAtoms is the cost in atoms (1 DCR = 1e11 atoms). The caller is responsible for converting from USD/DCR to atoms before calling this function. Returns true if the operation was successful, false otherwise.

func (*DBManager) Close

func (dm *DBManager) Close() error

Close closes the database connection

func (*DBManager) GetBalance

func (dm *DBManager) GetBalance(uid string) (int64, error)

GetBalance retrieves a user's balance

func (*DBManager) GetUserBalance

func (db *DBManager) GetUserBalance(uid []byte) (float64, error)

GetUserBalance gets the current balance of a user in DCR

func (*DBManager) UpdateBalance

func (dm *DBManager) UpdateBalance(uid string, amount int64) error

UpdateBalance updates a user's balance

type UserBalance

type UserBalance struct {
	UID     string
	Balance int64 // Balance in atoms (1 DCR = 1e11 atoms)
}

UserBalance represents a user's balance in the database

Jump to

Keyboard shortcuts

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