database

package
v0.0.0-...-1239126 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

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

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

	CreateCheckpointCursorsTable = `` /* 163-byte string literal not displayed */

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

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

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

	GetCheckpointCursorQuery = `
	SELECT last_sequence
	FROM sui.checkpoint_cursors
	WHERE id = $1
	`

	// UpsertCheckpointCursorQuery is monotonic: the stored sequence never regresses even if
	// callers race or submit stale values.
	UpsertCheckpointCursorQuery = `` /* 220-byte string literal not displayed */

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

func (store *DBStore) GetCheckpointCursor(ctx context.Context, id string) (seq uint64, found bool, err error)

GetCheckpointCursor returns the persisted last-processed checkpoint sequence for the given cursor id. found is false when no cursor has been persisted yet.

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)

func (*DBStore) UpsertCheckpointCursor

func (store *DBStore) UpsertCheckpointCursor(ctx context.Context, id string, seq uint64) error

UpsertCheckpointCursor persists the last-processed checkpoint sequence for the given cursor id. The stored value is monotonic: it never regresses to a lower sequence.

type EventRecord

type EventRecord struct {
	EventAccountAddress string
	EventHandle         string
	// TxIndex is the position of the transaction within its checkpoint, as returned by the node.
	// Together with (block_height, event_offset) it provides a total order across all events.
	TxIndex        uint64
	EventOffset    uint64
	TxDigest       string
	BlockVersion   uint64
	BlockHeight    string
	BlockHash      []byte
	BlockTimestamp uint64
	Data           map[string]any
	IsSynthetic    bool
}

Jump to

Keyboard shortcuts

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