postgres

package
v0.0.0-...-83927be Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transaction

func Transaction(db *DB, fn func(fidl.Queryable) error) (err error)

Types

type Account

type Account struct {
	ID        int64       `db:"id"`
	Address   string      `db:"wallet_address"`
	Type      AccountType `db:"account_type"`
	CreatedAt time.Time   `db:"created_at"`
	UpdatedAt time.Time   `db:"updated_at"`
}

type AccountType

type AccountType int8
const (
	StorageProvider AccountType = iota + 1
	Client
)

func (AccountType) String

func (a AccountType) String() string

type Authorization

type Authorization struct {
	ID        int64               `db:"id"`
	UUID      uuid.UUID           `db:"uuid"`
	Balance   types.FIL           `db:"balance"`
	Proxy     string              `db:"proxy"`
	Status    AuthorizationStatus `db:"status_id"`
	CreatedAt time.Time           `db:"created_at"`
	UpdatedAt time.Time           `db:"updated_at"`
}

type AuthorizationStatus

type AuthorizationStatus int8
const (
	AuthorizationOpen AuthorizationStatus = iota + 1
	AuthorizationLocked
)

func (AuthorizationStatus) String

func (a AuthorizationStatus) String() string

type BankConfig

type BankConfig struct {
	WalletAddress  string
	EscrowAddress  string
	EscrowDeadline string
}

type BankService

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

func NewBankService

func NewBankService(db *DB, cfg *BankConfig) *BankService

func (BankService) Authorize

func (s BankService) Authorize(address string, proxy string) (bank.AuthModel, error)

func (BankService) Balance

func (s BankService) Balance(address string) (types.FIL, types.FIL, error)

func (BankService) Deposit

func (s BankService) Deposit(address string, amount types.FIL, transactionHash string) (types.FIL, error)

func (BankService) Redeem

func (s BankService) Redeem(address string, id uuid.UUID, amount types.FIL) (bank.RedeemModel, error)

func (BankService) Refund

func (s BankService) Refund(address string) (bank.RefundModel, error)

func (BankService) RegisterProxy

func (s BankService) RegisterProxy(spid string, walletAddress string, price types.FIL) error

func (BankService) RegisterWithdrawTransaction

func (s BankService) RegisterWithdrawTransaction(address string, destination string, amount types.FIL, transactionHash string) error

func (BankService) ValidateBlockchainTransaction

func (s BankService) ValidateBlockchainTransaction(hash string) (bool, error)

func (BankService) Verify

func (s BankService) Verify(address string, uuid uuid.UUID, amount types.FIL) error

func (BankService) Withdraw

func (s BankService) Withdraw(address string, destination string, amount types.FIL) (types.FIL, error)

type Config

type Config struct {
	Dsn          string
	MaxOpenConns int
	MaxIdleConns int
	MaxIdleTime  string
}

type DB

type DB struct {
	*sqlx.DB
}

func Connect

func Connect(cfg Config) *DB

type TransactionStatus

type TransactionStatus int8
const (
	TransactionPending TransactionStatus = iota + 1
	TransactionCompleted
)

func (TransactionStatus) String

func (a TransactionStatus) String() string

Jump to

Keyboard shortcuts

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