Documentation ¶
Index ¶
- type DB
- func (d *DB) AddPushTokenDB(contract string) (*PushTokenDB, error)
- func (d *DB) Close()
- func (db *DB) DataTableExists(suffix string) (bool, error)
- func (db *DB) EventTableExists(suffix string) (bool, error)
- func (d *DB) GetPushTokenDB(contract string) (*PushTokenDB, bool)
- func (db *DB) LogTableExists(suffix string) (bool, error)
- func (db *DB) PushTokenTableExists(suffix string) (bool, error)
- func (db *DB) SponsorTableExists(suffix string) (bool, error)
- func (d *DB) TableNameSuffix(contract string) (string, error)
- type DataDB
- type EventDB
- func (db *EventDB) AddEvent(contract string, signature string, name string) error
- func (db *EventDB) CreateEventsTable(suffix string) error
- func (db *EventDB) CreateEventsTableIndexes(suffix string) error
- func (db *EventDB) GetEvent(contract string, signature string) (*engine.Event, error)
- func (db *EventDB) GetEvents() ([]*engine.Event, error)
- func (db *EventDB) GetOutdatedEvents(currentBlk int64) ([]*engine.Event, error)
- func (db *EventDB) SetEventLastBlock(contract string, signature string, lastBlock int64) error
- type LogDB
- func (db *LogDB) AddLog(lg *engine.Log) error
- func (db *LogDB) AddLogs(lg []*engine.Log) error
- func (db *LogDB) CreateLogTable() error
- func (db *LogDB) CreateLogTableIndexes() error
- func (db *LogDB) GetAllNewLogs(contract string, signature string, fromDate time.Time, limit, offset int) ([]*engine.Log, error)
- func (db *LogDB) GetAllPaginatedLogs(contract string, signature string, maxDate time.Time, limit, offset int) ([]*engine.Log, error)
- func (db *LogDB) GetLog(hash string) (*engine.Log, error)
- func (db *LogDB) GetNewLogs(contract string, signature string, fromDate time.Time, ...) ([]*engine.Log, error)
- func (db *LogDB) GetPaginatedLogs(contract string, signature string, maxDate time.Time, ...) ([]*engine.Log, error)
- func (db *LogDB) RemoveLog(hash string) error
- func (db *LogDB) RemoveOldInProgressLogs() error
- func (db *LogDB) SetStatus(status, hash string) error
- func (db *LogDB) UpdateLogsWithDB(txs []*engine.Log) ([]*engine.Log, error)
- type PushTokenDB
- func (db *PushTokenDB) AddToken(p *engine.PushToken) error
- func (db *PushTokenDB) CreatePushTable() error
- func (db *PushTokenDB) CreatePushTableIndexes() error
- func (db *PushTokenDB) GetAccountTokens(account string) ([]*engine.PushToken, error)
- func (db *PushTokenDB) RemoveAccountPushToken(token, account string) error
- func (db *PushTokenDB) RemovePushToken(token string) error
- type SponsorDB
- func (db *SponsorDB) AddSponsor(sponsor *engine.Sponsor) error
- func (db *SponsorDB) CreateSponsorsTable(suffix string) error
- func (db *SponsorDB) CreateSponsorsTableIndexes(suffix string) error
- func (db *SponsorDB) GetSponsor(contract string) (*engine.Sponsor, error)
- func (db *SponsorDB) UpdateSponsor(sponsor *engine.Sponsor) error
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) DataTableExists ¶
DataTableExists checks if a table exists in the database
func (*DB) EventTableExists ¶
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 ¶
LogTableExists checks if a table exists in the database
func (*DB) PushTokenTableExists ¶
PushTokenTableExists checks if a table exists in the database
func (*DB) SponsorTableExists ¶
SponsorTableExists checks if a table exists in the database
type DataDB ¶
type DataDB struct {
// contains filtered or unexported fields
}
func (*DataDB) CreateDataTable ¶
CreateDataTable creates a table to store extra data
func (*DataDB) CreateDataTableIndexes ¶
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 ¶
NewEventDB creates a new DB
func (*EventDB) CreateEventsTable ¶
createEventsTable creates a table to store events in the given db
func (*EventDB) CreateEventsTableIndexes ¶
createEventsTableIndexes creates the indexes for events in the given db
func (*EventDB) GetOutdatedEvents ¶
GetOutdatedEvents gets all queued events from the db sorted by created_at
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) CreateLogTable ¶
createLogTable creates a table dest store logs in the given db
func (*LogDB) CreateLogTableIndexes ¶
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) 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) RemoveOldInProgressLogs ¶
RemoveOldInProgressLogs removes any log that is not success or fail from the db
type PushTokenDB ¶
type PushTokenDB struct {
// contains filtered or unexported fields
}
func NewPushTokenDB ¶
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 ¶
AddSponsor adds a sponsor to the db
func (*SponsorDB) CreateSponsorsTable ¶
createSponsorsTable creates a table to store sponsors in the given db
func (*SponsorDB) CreateSponsorsTableIndexes ¶
createSponsorsTableIndexes creates the indexes for sponsors in the given db
func (*SponsorDB) GetSponsor ¶
GetSponsor gets a sponsor from the db by contract