migrations

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Continues string = "continues"

Continues is the latest Indexed Block Round.

View Source
const LastRetained string = "lastRetain"

LastRetained is the block with minimum height maintained.

Variables

View Source
var Migrations *migrator.Migrations

Migrations are all migrations.

Functions

func DropTables

func DropTables(ctx context.Context, db *bun.DB) error

DropTables deletes all database tables in the `public` schema of the configured database.

Note: this method assumes that PostgresSQL is used as the underlying db.

func Init

func Init(ctx context.Context, db *bun.DB) error

Init initializes the migrator tables.

func LogsUp

func LogsUp(ctx context.Context, tx *bun.Tx) error

LogsUp does performes the 20220109122505_logs up migration.

func Migrate

func Migrate(ctx context.Context, db *bun.DB) error

Migrate migrates the DB to latest version.

Types

type IndexedRoundWithTip

type IndexedRoundWithTip struct {
	Tip   string `bun:",pk"`
	Round uint64
}

type Log

type Log struct {
	Address   string
	Topics    []string
	Data      string
	Round     uint64 // BlockNumber
	BlockHash string
	TxHash    string `bun:",pk"`
	TxIndex   uint
	Index     uint `bun:",pk,allowzero"`
	Removed   bool
}

Log is the log representation in db.

type Storage

type Storage struct {
	DB bun.IDB
}

Storage is a db storage helper wrapper.

Avoid depending on storage gateway types and methods as the migration should be immutable and work on the state of the previous migration. Whereas the existing storage type and methods will always be compatible with the most recent db version.

func (*Storage) DeleteLogs

func (s *Storage) DeleteLogs(ctx context.Context, startRound uint64, endRound uint64) error

DeleteLogs deletes logs between rounds.

func (*Storage) GetLastIndexedRound

func (s *Storage) GetLastIndexedRound(ctx context.Context) (uint64, error)

GetLastIndexedRound returns latest indexed block round.

func (*Storage) GetLastRetainedRound

func (s *Storage) GetLastRetainedRound(ctx context.Context) (uint64, error)

GetLastRetainedRound returns the minimum round not pruned.

func (*Storage) GetLogs

func (s *Storage) GetLogs(ctx context.Context, startRound, endRound uint64) ([]*Log, error)

GetLogs return the logs for the round.

func (*Storage) InsertLogs

func (s *Storage) InsertLogs(ctx context.Context, values []*Log) error

InsertLogs inserts a batch of logs into the db.

func (*Storage) Upsert

func (s *Storage) Upsert(ctx context.Context, value interface{}) error

Upsert upserts a value.

type Transaction

type Transaction struct {
	Hash      string `bun:",pk"`
	Type      uint8
	Status    uint // tx/receipt status
	ChainID   string
	BlockHash string
	Round     uint64
	Index     uint32
	Gas       uint64
	GasPrice  string
	GasTipCap string
	GasFeeCap string
	Nonce     uint64
	FromAddr  string
	ToAddr    string
	Value     string
	Data      string
	V, R, S   string
}

Transaction is transaction representation in db.

Jump to

Keyboard shortcuts

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