db

package
v0.0.0-...-5882973 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	EventDB     *EventDB
	SponsorDB   *SponsorDB
	TransferDB  map[string]*TransferDB
	PushTokenDB map[string]*PushTokenDB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(chainID *big.Int, basePath, secret string) (*DB, error)

NewDB instantiates a new DB

func (*DB) AddPushTokenDB

func (d *DB) AddPushTokenDB(contract string) (*PushTokenDB, error)

AddPushTokenDB adds a new push token db for the given contract

func (*DB) AddTransferDB

func (d *DB) AddTransferDB(contract string) (*TransferDB, error)

AddTransferDB adds a new transfer db for the given contract

func (*DB) Close

func (d *DB) Close() error

Close closes the db and all its transfer and push dbs

func (*DB) EventTableExists

func (db *DB) EventTableExists(suffix string) (bool, error)

EventTableExists checks if a table exists in the database

func (*DB) GetPushTokenDB

func (d *DB) GetPushTokenDB(contract string) (*PushTokenDB, bool)

GetPushTokenDB returns true if the push token db for the given contract exists, returns the db if it exists

func (*DB) GetTransferDB

func (d *DB) GetTransferDB(contract string) (*TransferDB, bool)

GetTransferDB returns true if the transfer db for the given contract exists, returns the db if it exists

func (*DB) PushTokenTableExists

func (db *DB) PushTokenTableExists(suffix string) (bool, error)

PushTokenTableExists checks if a table exists in the database

func (*DB) SponsorTableExists

func (db *DB) SponsorTableExists(suffix string) (bool, error)

SponsorTableExists checks if a table exists in the database

func (*DB) TableNameSuffix

func (d *DB) TableNameSuffix(contract string) (string, error)

TableNameSuffix returns the name of the transfer db for the given contract

func (*DB) TransferTableExists

func (db *DB) TransferTableExists(suffix string) (bool, error)

TransferTableExists checks if a table exists in the database

type EventDB

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

func NewEventDB

func NewEventDB(db, rdb *sql.DB, name string) (*EventDB, error)

NewEventDB creates a new DB

func (*EventDB) AddEvent

func (db *EventDB) AddEvent(contract string, state indexer.EventState, startBlk, lastBlk int64, std indexer.Standard, name, symbol string, decimals int64) error

AddEvent adds an event to the db

func (*EventDB) Close

func (db *EventDB) Close() error

Close closes the db

func (*EventDB) CloseR

func (db *EventDB) CloseR() error

func (*EventDB) CreateEventsTable

func (db *EventDB) CreateEventsTable(suffix string) error

createEventsTable creates a table to store events in the given db

func (*EventDB) CreateEventsTableIndexes

func (db *EventDB) CreateEventsTableIndexes(suffix string) error

createEventsTableIndexes creates the indexes for events in the given db

func (*EventDB) GetEvent

func (db *EventDB) GetEvent(contract string, standard indexer.Standard) (*indexer.Event, error)

GetEvent gets an event from the db by contract and standard

func (*EventDB) GetEvents

func (db *EventDB) GetEvents() ([]*indexer.Event, error)

GetEvents gets all events from the db

func (*EventDB) GetOutdatedEvents

func (db *EventDB) GetOutdatedEvents(currentBlk int64) ([]*indexer.Event, error)

GetOutdatedEvents gets all queued events from the db sorted by created_at

func (*EventDB) GetQueuedEvents

func (db *EventDB) GetQueuedEvents() ([]*indexer.Event, error)

GetQueuedEvents gets all queued events from the db sorted by created_at

func (*EventDB) SetEventLastBlock

func (db *EventDB) SetEventLastBlock(contract string, standard indexer.Standard, lastBlock int64) error

SetEventLastBlock sets the last block of an event

func (*EventDB) SetEventState

func (db *EventDB) SetEventState(contract string, standard indexer.Standard, state indexer.EventState) error

SetEventState sets the state of an event

type PostgresDB

type PostgresDB struct {
	EventDB     *EventDB
	SponsorDB   *SponsorDB
	TransferDB  map[string]*TransferDB
	PushTokenDB map[string]*PushTokenDB
	// contains filtered or unexported fields
}

func NewPostgresDB

func NewPostgresDB(chainID *big.Int, username, password, name, host, rhost, secret string) (*PostgresDB, error)

func (*PostgresDB) AddPushTokenDB

func (d *PostgresDB) AddPushTokenDB(contract string) (*PushTokenDB, error)

AddPushTokenDB adds a new push token db for the given contract

func (*PostgresDB) AddTransferDB

func (d *PostgresDB) AddTransferDB(contract string) (*TransferDB, error)

AddTransferDB adds a new transfer db for the given contract

func (*PostgresDB) Close

func (d *PostgresDB) Close() error

Close closes the db and all its transfer and push dbs

func (*PostgresDB) EventTableExists

func (db *PostgresDB) EventTableExists(suffix string) (bool, error)

EventTableExists checks if a table exists in the database

func (*PostgresDB) GetPushTokenDB

func (d *PostgresDB) GetPushTokenDB(contract string) (*PushTokenDB, bool)

GetPushTokenDB returns true if the push token db for the given contract exists, returns the db if it exists

func (*PostgresDB) GetTransferDB

func (d *PostgresDB) GetTransferDB(contract string) (*TransferDB, bool)

GetTransferDB returns true if the transfer db for the given contract exists, returns the db if it exists

func (*PostgresDB) Migrate

func (d *PostgresDB) Migrate(sqdb *DB, token, paymaster string, txBatchSize int) error

Migrate to Sqlite db

func (*PostgresDB) PushTokenTableExists

func (db *PostgresDB) PushTokenTableExists(suffix string) (bool, error)

PushTokenTableExists checks if a table exists in the database

func (*PostgresDB) SponsorTableExists

func (db *PostgresDB) SponsorTableExists(suffix string) (bool, error)

SponsorTableExists checks if a table exists in the database

func (*PostgresDB) TableNameSuffix

func (d *PostgresDB) TableNameSuffix(contract string) (string, error)

TableNameSuffix returns the name of the transfer db for the given contract

func (*PostgresDB) TransferTableExists

func (db *PostgresDB) TransferTableExists(suffix string) (bool, error)

TransferTableExists checks if a table exists in the database

type PushTokenDB

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

func NewPushTokenDB

func NewPushTokenDB(db, rdb *sql.DB, name string) (*PushTokenDB, error)

NewPushTokenDB creates a new DB

func (*PushTokenDB) AddToken

func (db *PushTokenDB) AddToken(p *indexer.PushToken) error

AddToken adds a token to the db

func (*PushTokenDB) Close

func (db *PushTokenDB) Close() error

Close closes the db

func (*PushTokenDB) CloseR

func (db *PushTokenDB) CloseR() error

func (*PushTokenDB) CreatePushTable

func (db *PushTokenDB) CreatePushTable() error

CreatePushTable creates a table to store push tokens in the given db

func (*PushTokenDB) CreatePushTableIndexes

func (db *PushTokenDB) CreatePushTableIndexes() error

CreatePushTableIndexes creates the indexes for push in the given db

func (*PushTokenDB) GetAccountTokens

func (db *PushTokenDB) GetAccountTokens(account string) ([]*indexer.PushToken, error)

GetAccountTokens returns the push tokens for a given account

func (*PushTokenDB) RemoveAccountPushToken

func (db *PushTokenDB) RemoveAccountPushToken(token, account string) error

RemoveAccountPushToken removes a push token for a given account from the db

func (*PushTokenDB) RemovePushToken

func (db *PushTokenDB) RemovePushToken(token string) error

RemovePushToken removes a push token from the db

type SponsorDB

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

func NewSponsorDB

func NewSponsorDB(db, rdb *sql.DB, name, secret string) (*SponsorDB, error)

NewSponsorDB creates a new DB

func (*SponsorDB) AddSponsor

func (db *SponsorDB) AddSponsor(sponsor *indexer.Sponsor) error

AddSponsor adds a sponsor to the db

func (*SponsorDB) Close

func (db *SponsorDB) Close() error

Close closes the db

func (*SponsorDB) CloseR

func (db *SponsorDB) CloseR() error

func (*SponsorDB) CreateSponsorsTable

func (db *SponsorDB) CreateSponsorsTable(suffix string) error

createSponsorsTable creates a table to store sponsors in the given db

func (*SponsorDB) CreateSponsorsTableIndexes

func (db *SponsorDB) CreateSponsorsTableIndexes(suffix string) error

createSponsorsTableIndexes creates the indexes for sponsors in the given db

func (*SponsorDB) GetSponsor

func (db *SponsorDB) GetSponsor(contract string) (*indexer.Sponsor, error)

GetSponsor gets a sponsor from the db by contract

func (*SponsorDB) UpdateSponsor

func (db *SponsorDB) UpdateSponsor(sponsor *indexer.Sponsor) error

UpdateSponsor updates a sponsor in the db

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 *indexer.Transfer) error

AddTransfer adds a transfer to the db

func (*TransferDB) AddTransfers

func (db *TransferDB) AddTransfers(tx []*indexer.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) GetAllPaginatedTransfers

func (db *TransferDB) GetAllPaginatedTransfers(tokenId int64, maxDate time.Time, limit, offset int) ([]*indexer.Transfer, error)

GetAllPaginatedTransfers returns the transfers paginated

func (*TransferDB) GetNewTransfers

func (db *TransferDB) GetNewTransfers(tokenId int64, addr string, fromDate time.Time, limit int) ([]*indexer.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) ([]*indexer.Transfer, error)

GetPaginatedTransfers returns the transfers for a given from_addr or to_addr paginated

func (*TransferDB) GetProcessingTransfers

func (db *TransferDB) GetProcessingTransfers(limit int) ([]*indexer.Transfer, error)

GetProcessingTransfers returns the transfers for a given from_addr or to_addr from a given date

func (*TransferDB) GetTransfer

func (db *TransferDB) GetTransfer(hash string) (*indexer.Transfer, error)

GetTransfer returns the transfer for a given hash

func (*TransferDB) ReconcileTx

func (db *TransferDB) ReconcileTx(txHash, hash string, nonce int64) error

SetTxHash sets the tx hash of a transfer with no tx_hash

func (*TransferDB) ReconcileTxHash

func (db *TransferDB) ReconcileTxHash(tx *indexer.Transfer) error

ReconcileTxHash updates transfers to ensure that there are no duplicates

func (*TransferDB) RemoveOldInProgressTransfers

func (db *TransferDB) RemoveOldInProgressTransfers() error

RemoveOldInProgressTransfers removes any transfer that is not success or fail from the db

func (*TransferDB) RemovePendingTransfer

func (db *TransferDB) RemovePendingTransfer(hash string) error

RemovePendingTransfer removes a pending transfer from the db

func (*TransferDB) RemoveSendingTransfer

func (db *TransferDB) RemoveSendingTransfer(hash string) error

RemoveSendingTransfer removes a sending transfer from the db

func (*TransferDB) RemoveTransfer

func (db *TransferDB) RemoveTransfer(hash string) error

RemoveTransfer removes a sending transfer from the db

func (*TransferDB) SetFinalHash

func (db *TransferDB) SetFinalHash(txHash, hash string) error

SetFinalHash sets the hash of a transfer with no tx_hash

func (*TransferDB) SetStatus

func (db *TransferDB) SetStatus(status, hash string) error

SetStatus sets the status of a transfer to pending

func (*TransferDB) SetStatusFromHash

func (db *TransferDB) SetStatusFromHash(status, hash string) error

SetStatusFromTxHash sets the status of a transfer to pending

func (*TransferDB) SetTxHash

func (db *TransferDB) SetTxHash(txHash, hash string) error

SetTxHash sets the tx hash of a transfer with no tx_hash

func (*TransferDB) TransferExists

func (db *TransferDB) TransferExists(txHash, from, to, value string) (bool, error)

TransferExists returns true if the transfer tx_hash exists in the db

func (*TransferDB) TransferSimilarExists

func (db *TransferDB) TransferSimilarExists(from, to, value string) (string, error)

TransferSimilarExists returns true if the transfer tx_hash is empty and to, from and value match in the db

func (*TransferDB) UpdateTransfersWithDB

func (db *TransferDB) UpdateTransfersWithDB(txs []*indexer.Transfer) ([]*indexer.Transfer, error)

UpdateTransfersWithDB returns the transfers with data updated from the db

Jump to

Keyboard shortcuts

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