database

package
v0.0.0-...-e90b556 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateSchema = `
        CREATE SCHEMA IF NOT EXISTS sui;
    `

	CreateEventsTable = `` /* 428-byte string literal not displayed */

	CreateIndices = `` /* 331-byte string literal not displayed */

	InsertEvent = `` /* 249-byte string literal not displayed */

	QueryEventsBase = `` /* 544-byte string literal not displayed */

	QueryEventsOffset = `` /* 198-byte string literal not displayed */

	CountEvents = `
	SELECT COUNT(*) as total_count
	FROM sui.events 
	WHERE event_account_address = $1 AND event_handle = $2 
	`

	GetTxDigestById = `
	SELECT tx_digest
	FROM sui.events
	WHERE id = $1
	`
)
View Source
const (
	MaxEventsQueryLimit = 2000
)

Variables

This section is empty.

Functions

func BuildSQLCondition

func BuildSQLCondition(expr query.Expression, args *[]any, argCount *int) (string, error)

Taken from the Aptos ChainReader DB methods: https://github.com/smartcontractkit/chainlink-aptos/blob/develop/relayer/chainreader/db/db.go#L257

Types

type DBStore

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

func NewDBStore

func NewDBStore(ds sqlutil.DataSource, lgr logger.Logger) *DBStore

func (*DBStore) EnsureSchema

func (store *DBStore) EnsureSchema(ctx context.Context) error

func (*DBStore) GetLatestOffset

func (store *DBStore) GetLatestOffset(ctx context.Context, eventAccountAddress, eventHandle string) (*models.EventId, uint64, error)

GetLatestOffset returns a cursor (of type EventId) based on the latest event recorded in the DB for a given type

func (*DBStore) GetTotalCount

func (store *DBStore) GetTotalCount(ctx context.Context, eventAccountAddress, eventHandle string) (uint64, error)

GetTotalCount returns the total number of events recorded in the DB for a given type

func (*DBStore) GetTxDigestByEventId

func (store *DBStore) GetTxDigestByEventId(ctx context.Context, eventID uint64) (string, error)

func (*DBStore) InsertEvents

func (store *DBStore) InsertEvents(ctx context.Context, records []EventRecord) error

func (*DBStore) QueryEvents

func (store *DBStore) QueryEvents(ctx context.Context, eventAccountAddress, eventHandle string, expressions []query.Expression, limitAndSort query.LimitAndSort) ([]EventRecord, error)

type EventRecord

type EventRecord struct {
	EventAccountAddress string
	EventHandle         string
	EventOffset         uint64
	TxDigest            string
	BlockVersion        uint64
	BlockHeight         string
	BlockHash           []byte
	BlockTimestamp      uint64
	Data                map[string]any
}

Jump to

Keyboard shortcuts

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