mtransfer

package
v0.0.0-...-4b9a48e Latest Latest
Warning

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

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

Documentation

Index

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 (t *Transfer) CombineFromTo() string

func (*Transfer) GenerateUniqueHash

func (t *Transfer) GenerateUniqueHash() string

generate hash for transfer using a provided index, from, to and the tx hash

func (*Transfer) ToRounded

func (t *Transfer) ToRounded(decimals int64) float64

func (*Transfer) Update

func (t *Transfer) Update(tx *Transfer)

Update updates the transfer using the given transfer

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) Close

func (db *TransferDB) Close() error

Close closes 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

func (TransferData) Value

func (td TransferData) Value() (driver.Value, error)

TransferData implements the driver.Valuer 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)

Jump to

Keyboard shortcuts

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