db

package
v0.0.0-...-7a1e3be Latest Latest
Warning

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

Go to latest
Published: Nov 27, 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
	LogDB       *LogDB
	PushTokenDB map[string]*PushTokenDB
	// contains filtered or unexported fields
}

func NewDB

func NewDB(chainID *big.Int, secret, username, password, dbname, port, host, rhost 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) Close

func (d *DB) Close()

Close closes the db and all its transfer and push dbs

func (*DB) DataTableExists

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

DataTableExists checks if a table exists in the database

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

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

LogTableExists checks if a table exists in the database

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

type DataDB

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

func NewDataDB

func NewDataDB(ctx context.Context, db, rdb *pgxpool.Pool, name string) (*DataDB, error)

NewDataDB creates a new DB

func (*DataDB) CreateDataTable

func (db *DataDB) CreateDataTable() error

CreateDataTable creates a table to store extra data

func (*DataDB) CreateDataTableIndexes

func (db *DataDB) CreateDataTableIndexes() error

CreateDataTableIndexes creates the indexes for the data table

func (*DataDB) GetData

func (db *DataDB) GetData(hash string) (*json.RawMessage, error)

GetData retrieves data for a given hash

func (*DataDB) UpsertData

func (db *DataDB) UpsertData(hash string, data *json.RawMessage) error

UpsertData adds or updates data for a given hash

type EventDB

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

func NewEventDB

func NewEventDB(ctx context.Context, db, rdb *pgxpool.Pool, name string) (*EventDB, error)

NewEventDB creates a new DB

func (*EventDB) AddEvent

func (db *EventDB) AddEvent(contract string, signature string, name string) error

AddEvent adds an event to the db

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, signature string) (*engine.Event, error)

GetEvent gets an event from the db by contract and signature

func (*EventDB) GetEvents

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

GetEvents gets all events from the db

func (*EventDB) GetOutdatedEvents

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

GetOutdatedEvents gets all queued events from the db sorted by created_at

func (*EventDB) SetEventLastBlock

func (db *EventDB) SetEventLastBlock(contract string, signature string, lastBlock int64) error

SetEventLastBlock sets the last block of an event

type LogDB

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

func NewLogDB

func NewLogDB(ctx context.Context, db, rdb *pgxpool.Pool, name string, datadb *DataDB) (*LogDB, error)

NewLogDB creates a new DB

func (*LogDB) AddLog

func (db *LogDB) AddLog(lg *engine.Log) error

AddLog adds a log dest the db

func (*LogDB) AddLogs

func (db *LogDB) AddLogs(lg []*engine.Log) error

AddLogs adds a list of logs dest the db

func (*LogDB) CreateLogTable

func (db *LogDB) CreateLogTable() error

createLogTable creates a table dest store logs in the given db

func (*LogDB) CreateLogTableIndexes

func (db *LogDB) CreateLogTableIndexes() error

createLogTableIndexes creates the indexes for logs in the given db

func (*LogDB) GetAllNewLogs

func (db *LogDB) GetAllNewLogs(contract string, signature string, fromDate time.Time, limit, offset int) ([]*engine.Log, error)

GetAllNewLogs returns the logs for a given from_addr or to_addr from a given date

func (*LogDB) GetAllPaginatedLogs

func (db *LogDB) GetAllPaginatedLogs(contract string, signature string, maxDate time.Time, limit, offset int) ([]*engine.Log, error)

GetAllPaginatedLogs returns the logs paginated

func (*LogDB) GetLog

func (db *LogDB) GetLog(hash string) (*engine.Log, error)

GetLog returns the log for a given hash

func (*LogDB) GetNewLogs

func (db *LogDB) GetNewLogs(contract string, signature string, fromDate time.Time, dataFilters, dataFilters2 map[string]any, limit, offset int) ([]*engine.Log, error)

GetNewLogs returns the logs for a given from_addr or to_addr from a given date

func (*LogDB) GetPaginatedLogs

func (db *LogDB) GetPaginatedLogs(contract string, signature string, maxDate time.Time, dataFilters, dataFilters2 map[string]any, limit, offset int) ([]*engine.Log, error)

GetPaginatedLogs returns the logs for a given from_addr or to_addr paginated

func (*LogDB) RemoveLog

func (db *LogDB) RemoveLog(hash string) error

RemoveLog removes a sending log from the db

func (*LogDB) RemoveOldInProgressLogs

func (db *LogDB) RemoveOldInProgressLogs() error

RemoveOldInProgressLogs removes any log that is not success or fail from the db

func (*LogDB) SetStatus

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

SetStatus sets the status of a log dest pending

func (*LogDB) UpdateLogsWithDB

func (db *LogDB) UpdateLogsWithDB(txs []*engine.Log) ([]*engine.Log, error)

UpdateLogsWithDB returns the logs with data updated from the db

type PushTokenDB

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

func NewPushTokenDB

func NewPushTokenDB(ctx context.Context, db, rdb *pgxpool.Pool, name string) (*PushTokenDB, error)

NewPushTokenDB creates a new DB

func (*PushTokenDB) AddToken

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

AddToken adds a token to the db

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) ([]*engine.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(ctx context.Context, db, rdb *pgxpool.Pool, name, secret string) (*SponsorDB, error)

NewSponsorDB creates a new DB

func (*SponsorDB) AddSponsor

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

AddSponsor adds a sponsor to the db

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) (*engine.Sponsor, error)

GetSponsor gets a sponsor from the db by contract

func (*SponsorDB) UpdateSponsor

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

UpdateSponsor updates a sponsor in the db

Jump to

Keyboard shortcuts

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