Documentation ¶
Index ¶
- type Transfer
- type TransferDB
- func (db *TransferDB) AddTransfer(tx *Transfer) error
- func (db *TransferDB) AddTransfers(tx []*Transfer) error
- func (db *TransferDB) Close() error
- func (db *TransferDB) CloseR() error
- func (db *TransferDB) CreateTransferTable() error
- func (db *TransferDB) CreateTransferTableIndexes() error
- func (db *TransferDB) GetAllNewTransfers(tokenId int64, fromDate time.Time, limit, offset int) ([]*Transfer, error)
- func (db *TransferDB) GetAllPaginatedTransfers(tokenId int64, maxDate time.Time, limit, offset int) ([]*Transfer, error)
- func (db *TransferDB) GetNewTransfers(tokenId int64, addr string, fromDate time.Time, limit, offset int) ([]*Transfer, error)
- func (db *TransferDB) GetPaginatedTransfers(tokenId int64, addr string, maxDate time.Time, limit, offset int) ([]*Transfer, error)
- func (db *TransferDB) GetTransfer(hash string) (*Transfer, error)
- func (db *TransferDB) RemoveOldInProgressTransfers() error
- func (db *TransferDB) RemoveTransfer(hash string) error
- func (db *TransferDB) SetStatus(status, hash string) error
- func (db *TransferDB) UpdateTransfersWithDB(txs []*Transfer) ([]*Transfer, error)
- type TransferData
- type TransferStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Transfer ¶
type Transfer struct { Hash string `json:"hash"` TxHash string `json:"tx_hash"` TokenID int64 `json:"token_id"` CreatedAt time.Time `json:"created_at"` FromTo string `json:"-"` From string `json:"from"` To string `json:"to"` Nonce int64 `json:"nonce"` Value *big.Int `json:"value"` Data *TransferData `json:"data"` Status TransferStatus `json:"status"` }
func (*Transfer) CombineFromTo ¶
func (*Transfer) GenerateUniqueHash ¶
generate hash for transfer using a provided index, from, to and the tx hash
type TransferDB ¶
type TransferDB struct {
// contains filtered or unexported fields
}
func NewTransferDB ¶
func NewTransferDB(db, rdb *sql.DB, name string) (*TransferDB, error)
NewTransferDB creates a new DB
func (*TransferDB) AddTransfer ¶
func (db *TransferDB) AddTransfer(tx *Transfer) error
AddTransfer adds a transfer to the db
func (*TransferDB) AddTransfers ¶
func (db *TransferDB) AddTransfers(tx []*Transfer) error
AddTransfers adds a list of transfers to the db
func (*TransferDB) CloseR ¶
func (db *TransferDB) CloseR() error
func (*TransferDB) CreateTransferTable ¶
func (db *TransferDB) CreateTransferTable() error
createTransferTable creates a table to store transfers in the given db from_to_addr is an optimization column to allow searching for transfers withouth using OR
func (*TransferDB) CreateTransferTableIndexes ¶
func (db *TransferDB) CreateTransferTableIndexes() error
createTransferTableIndexes creates the indexes for transfers in the given db
func (*TransferDB) GetAllNewTransfers ¶
func (db *TransferDB) GetAllNewTransfers(tokenId int64, fromDate time.Time, limit, offset int) ([]*Transfer, error)
GetNewTransfers returns the transfers for a given from_addr or to_addr from a given date
func (*TransferDB) GetAllPaginatedTransfers ¶
func (db *TransferDB) GetAllPaginatedTransfers(tokenId int64, maxDate time.Time, limit, offset int) ([]*Transfer, error)
GetAllPaginatedTransfers returns the transfers paginated
func (*TransferDB) GetNewTransfers ¶
func (db *TransferDB) GetNewTransfers(tokenId int64, addr string, fromDate time.Time, limit, offset int) ([]*Transfer, error)
GetNewTransfers returns the transfers for a given from_addr or to_addr from a given date
func (*TransferDB) GetPaginatedTransfers ¶
func (db *TransferDB) GetPaginatedTransfers(tokenId int64, addr string, maxDate time.Time, limit, offset int) ([]*Transfer, error)
GetPaginatedTransfers returns the transfers for a given from_addr or to_addr paginated
func (*TransferDB) GetTransfer ¶
func (db *TransferDB) GetTransfer(hash string) (*Transfer, error)
GetTransfer returns the transfer for a given hash
func (*TransferDB) RemoveOldInProgressTransfers ¶
func (db *TransferDB) RemoveOldInProgressTransfers() error
RemoveOldInProgressTransfers removes any transfer that is not success or fail from the db
func (*TransferDB) RemoveTransfer ¶
func (db *TransferDB) RemoveTransfer(hash string) error
RemoveTransfer removes a sending transfer from the db
func (*TransferDB) SetStatus ¶
func (db *TransferDB) SetStatus(status, hash string) error
SetStatus sets the status of a transfer to pending
func (*TransferDB) UpdateTransfersWithDB ¶
func (db *TransferDB) UpdateTransfersWithDB(txs []*Transfer) ([]*Transfer, error)
UpdateTransfersWithDB returns the transfers with data updated from the db
type TransferData ¶
type TransferData struct {
Description string `json:"description"`
}
func (*TransferData) Scan ¶
func (td *TransferData) Scan(value interface{}) error
TransferData implements the sql.Scanner interface
type TransferStatus ¶
type TransferStatus string
const ( TransferStatusUnknown TransferStatus = "" TransferStatusSending TransferStatus = "sending" TransferStatusPending TransferStatus = "pending" TransferStatusSuccess TransferStatus = "success" TransferStatusFail TransferStatus = "fail" TEMP_HASH_PREFIX = "TEMP_HASH" )
func TransferStatusFromString ¶
func TransferStatusFromString(s string) (TransferStatus, error)