db

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

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*pg.DB
}

Database implements a wrapper of golang ORM with focus on PostgreSQL

func Connect

func Connect(cfg config.DBConfig) *Database

Connect opens a database connections with the given database connection info from config. It returns a database connection handle or an error if the connection fails.

func (*Database) CreateTables

func (db *Database) CreateTables() error

CreateTables creates database tables using object relational mapping (ORM)

func (*Database) ExistValidator

func (db *Database) ExistValidator(valAddr string) (bool, error)

ExistValidator returns boolean after checking if a validator exists in database.

func (*Database) InsertExportedData

func (db *Database) InsertExportedData(block *schema.Block, txs []*schema.Transaction,
	vals []*schema.Validator, precommits []*schema.PreCommit) error

InsertExportedData inserts exported block, transaction data RunInTransaction runs a function in a transaction. if function returns an error transaction is rollbacked, otherwise transaction is committed.

func (*Database) Ping

func (db *Database) Ping() error

Ping returns a database connection handle or an error if the connection fails.

func (*Database) QueryLatestBlockHeight

func (db *Database) QueryLatestBlockHeight() (int64, error)

QueryLatestBlockHeight queries latest block height in database.

func (*Database) QueryValidatorMoniker

func (db *Database) QueryValidatorMoniker(valAddr string) string

QueryValidatorMoniker returns validator's moniker.

Jump to

Keyboard shortcuts

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