database

package
v0.0.0-...-8896b81 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addresses

type Addresses struct {
	GUID        uuid.UUID      `gorm:"primaryKey" json:"guid"`
	UserUid     string         `json:"user_uid"`
	Address     common.Address `json:"address" gorm:"serializer:bytes"`
	AddressType uint8          `json:"address_type"` //0:用户地址;1:热钱包地址(归集地址);2:冷钱包地址
	PrivateKey  string         `json:"private_key"`
	PublicKey   string         `json:"public_key"`
	Timestamp   uint64
}

type AddressesDB

type AddressesDB interface {
	AddressesView

	StoreAddressess([]Addresses, uint64) error
}

func NewAddressesDB

func NewAddressesDB(db *gorm.DB) AddressesDB

type AddressesView

type AddressesView interface {
	QueryAddressesByToAddress(*common.Address) (*Addresses, error)
	QueryHotWalletInfo() (*Addresses, error)
	QueryColdWalletInfo() (*Addresses, error)
}

type Balances

type Balances struct {
	GUID         uuid.UUID      `gorm:"primaryKey" json:"guid"`
	Address      common.Address `json:"address" gorm:"serializer:bytes"`
	TokenAddress common.Address `json:"token_address" gorm:"serializer:bytes"`
	AddressType  uint8          `json:"address_type"` //0:用户地址;1:热钱包地址(归集地址);2:冷钱包地址
	Balance      *big.Int       `gorm:"serializer:u256;column:balance" db:"balance" json:"Balance" form:"balance"`
	LockBalance  *big.Int       `gorm:"serializer:u256;column:lock_balance" db:"lock_balance" json:"LockBalance" form:"lock_balance"`
	Timestamp    uint64
}

type BalancesDB

type BalancesDB interface {
	BalancesView

	UpdateOrCreate([]TokenBalance) error
	StoreBalances([]Balances, uint64) error
	UpdateBalances([]Balances, bool) error
}

func NewBalancesDB

func NewBalancesDB(db *gorm.DB) BalancesDB

type BalancesView

type BalancesView interface {
	QueryWalletBalanceByTokenAndAddress(address, tokenAddress common.Address) (*Balances, error)
	UnCollectionList(amount *big.Int) ([]Balances, error)
	QueryHotWalletBalances(amount *big.Int) ([]Balances, error)
	QueryBalancesByToAddress(address *common.Address) (*Balances, error)
}

type Blocks

type Blocks struct {
	Hash       common.Hash `gorm:"primaryKey;serializer:bytes"`
	ParentHash common.Hash `gorm:"serializer:bytes"`
	Number     *big.Int    `gorm:"serializer:u256"`
	Timestamp  uint64
	RLPHeader  *common2.RLPHeader `gorm:"serializer:rlp;column:rlp_bytes"`
}

func BlockHeaderFromHeader

func BlockHeaderFromHeader(header *types.Header) Blocks

type BlocksDB

type BlocksDB interface {
	BlocksView

	StoreBlockss([]Blocks, uint64) error
}

func NewBlocksDB

func NewBlocksDB(db *gorm.DB) BlocksDB

type BlocksView

type BlocksView interface {
	LatestBlocks() (*Blocks, error)
}

type DB

type DB struct {
	Blocks       BlocksDB
	Addresses    AddressesDB
	Balances     BalancesDB
	Deposits     DepositsDB
	Withdraws    WithdrawsDB
	Transactions TransactionsDB
	Tokens       TokensDB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(ctx context.Context, dbConfig config.DBConfig) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ExecuteSQLMigration

func (db *DB) ExecuteSQLMigration(migrationsFolder string) error

func (*DB) Transaction

func (db *DB) Transaction(fn func(db *DB) error) error

type Deposits

type Deposits struct {
	GUID             uuid.UUID      `gorm:"primaryKey" json:"guid"`
	BlockHash        common.Hash    `gorm:"column:block_hash;serializer:bytes"  db:"block_hash" json:"block_hash"`
	BlockNumber      *big.Int       `gorm:"serializer:u256;column:block_number" db:"block_number" json:"BlockNumber" form:"block_number"`
	Hash             common.Hash    `gorm:"column:hash;serializer:bytes"  db:"hash" json:"hash"`
	FromAddress      common.Address `json:"from_address" gorm:"serializer:bytes;column:from_address"`
	ToAddress        common.Address `json:"to_address" gorm:"serializer:bytes;column:to_address"`
	TokenAddress     common.Address `json:"token_address" gorm:"serializer:bytes;column:token_address"`
	Fee              *big.Int       `gorm:"serializer:u256;column:fee" db:"fee" json:"Fee" form:"fee"`
	Amount           *big.Int       `gorm:"serializer:u256;column:amount" db:"amount" json:"Amount" form:"amount"`
	Status           uint8          `json:"status"` //0:充值确认中,1:充值钱包层已到账;2:充值已通知业务层;3:充值完成
	TransactionIndex *big.Int       `gorm:"serializer:u256;column:transaction_index" db:"transaction_index" json:"TransactionIndex" form:"transaction_index"`
	Timestamp        uint64
}

type DepositsDB

type DepositsDB interface {
	DepositsView

	StoreDeposits([]Deposits, uint64) error
	UpdateDepositsStatus(blockNumber uint64) error
}

func NewDepositsDB

func NewDepositsDB(db *gorm.DB) DepositsDB

type DepositsView

type DepositsView interface {
	ApiDepositList(string, int, int, string) ([]Deposits, int64)
}

type TokenBalance

type TokenBalance struct {
	Address      common.Address `json:"address"`
	TokenAddress common.Address `json:"to_ken_address"`
	Balance      *big.Int       `json:"balance"`
	LockBalance  *big.Int       `json:"lock_balance"`
	TxType       uint8          `json:"tx_type"` // 0:充值;1:提现;2:归集;3:热转冷;4:冷转热
}

type Tokens

type Tokens struct {
	GUID          uuid.UUID      `gorm:"primaryKey" json:"guid"`
	TokenAddress  common.Address `json:"token_address" gorm:"serializer:bytes"`
	Uint          uint8          `json:"uint"`
	TokenName     string         `json:"tokens_name"`
	CollectAmount *big.Int       `gorm:"serializer:u256;column:collect_amount" db:"collect_amount" json:"CollectAmount" form:"collect_amount"`
	Timestamp     uint64
}

type TokensDB

type TokensDB interface {
	TokensView

	StoreTokens([]Tokens, uint64) error
}

func NewTokensDB

func NewTokensDB(db *gorm.DB) TokensDB

type TokensView

type TokensView interface {
	TokensInfoByAddress(string) (*Tokens, error)
}

type Transactions

type Transactions struct {
	GUID             uuid.UUID      `gorm:"primaryKey" json:"guid"`
	BlockHash        common.Hash    `gorm:"column:block_hash;serializer:bytes"  db:"block_hash" json:"block_hash"`
	BlockNumber      *big.Int       `gorm:"serializer:u256;column:block_number" db:"block_number" json:"BlockNumber" form:"block_number"`
	Hash             common.Hash    `gorm:"column:hash;serializer:bytes"  db:"hash" json:"hash"`
	FromAddress      common.Address `json:"from_address" gorm:"serializer:bytes"`
	ToAddress        common.Address `json:"to_address" gorm:"serializer:bytes"`
	TokenAddress     common.Address `json:"token_address" gorm:"serializer:bytes"`
	Fee              *big.Int       `gorm:"serializer:u256;column:fee" db:"fee" json:"Fee" form:"fee"`
	Amount           *big.Int       `gorm:"serializer:u256;column:amount" db:"amount" json:"Amount" form:"amount"`
	Status           uint8          `json:"status"`  // 0:交易确认中,1:钱包交易已到账;2:交易已通知业务层;3:交易完成
	TxType           uint8          `json:"tx_type"` // 0:充值;1:提现;2:归集;3:热转冷;4:冷转热
	TransactionIndex *big.Int       `gorm:"serializer:u256;column:transaction_index" db:"transaction_index" json:"TransactionIndex" form:"transaction_index"`
	Timestamp        uint64
}

type TransactionsDB

type TransactionsDB interface {
	TransactionsView

	StoreTransactions([]Transactions, uint64) error
	UpdateTransactionsStatus(blockNumber *big.Int) error
	UpdateTransactionStatus(txList []Transactions) error
}

func NewTransactionsDB

func NewTransactionsDB(db *gorm.DB) TransactionsDB

type TransactionsView

type TransactionsView interface {
	QueryTransactionByHash(hash common.Hash) (*Transactions, error)
}

type Withdraws

type Withdraws struct {
	GUID             uuid.UUID      `gorm:"primaryKey" json:"guid"`
	BlockHash        common.Hash    `gorm:"column:block_hash;serializer:bytes"  db:"block_hash" json:"block_hash"`
	BlockNumber      *big.Int       `gorm:"serializer:u256;column:block_number" db:"block_number" json:"BlockNumber" form:"block_number"`
	Hash             common.Hash    `gorm:"column:hash;serializer:bytes"  db:"hash" json:"hash"`
	FromAddress      common.Address `json:"from_address" gorm:"serializer:bytes;column:from_address"`
	ToAddress        common.Address `json:"to_address" gorm:"serializer:bytes;column:to_address"`
	TokenAddress     common.Address `json:"token_address" gorm:"serializer:bytes;column:token_address"`
	Fee              *big.Int       `gorm:"serializer:u256;column:fee" db:"fee" json:"Fee" form:"fee"`
	Amount           *big.Int       `gorm:"serializer:u256;column:amount" db:"amount" json:"Amount" form:"amount"`
	Status           uint8          `json:"status"` // 0:提现未签名发送,1:提现已经发送到区块链网络;2:提现已上链;3:提现在钱包层已完成;4:提现已通知业务;5:提现成功
	TransactionIndex *big.Int       `gorm:"serializer:u256;column:transaction_index" db:"transaction_index" json:"TransactionIndex" form:"transaction_index"`
	TxSignHex        string         `json:"tx_sign_hex" gorm:"column:tx_sign_hex"`
	Timestamp        uint64
}

type WithdrawsDB

type WithdrawsDB interface {
	WithdrawsView

	StoreWithdraws([]Withdraws, uint64) error
	UpdateTransactionStatus(withdrawsList []Withdraws) error
	MarkWithdrawsToSend(withdrawsList []Withdraws) error
}

func NewWithdrawsDB

func NewWithdrawsDB(db *gorm.DB) WithdrawsDB

type WithdrawsView

type WithdrawsView interface {
	QueryWithdrawsByHash(hash common.Hash) (*Withdraws, error)
	UnSendWithdrawsList() ([]Withdraws, error)
	ApiWithdrawList(string, int, int, string) ([]Withdraws, int64)

	SubmitWithdrawFromBusiness(fromAddress common.Address, toAddress common.Address, TokenAddress common.Address, amount *big.Int) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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