postgresql

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: CC0-1.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Builder

func Builder(cfg *config.PostgreSQLConfig, codec *codec.Codec) (db.Database, error)

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

Types

type Database

type Database struct {
	Sql   *sql.DB
	Codec *codec.Codec
}

Database defines a wrapper around a SQL database and implements functionality for data aggregation and exporting.

func (Database) HasBlock

func (db Database) HasBlock(height int64) (bool, error)

HasBlock returns true if a block by height exists. An error should never be returned.

func (Database) HasValidator

func (db Database) HasValidator(addr string) (bool, error)

HasValidator returns true if a given validator by HEX address exists. An error should never be returned.

func (Database) LastBlockHeight

func (db Database) LastBlockHeight() (int64, error)

LastBlockHeight returns the latest block stored.

func (Database) SaveBlock

func (db Database) SaveBlock(block *tmctypes.ResultBlock, totalGas, preCommits uint64) error

SetBlock stores a block and returns the resulting record ID. An error is returned if the operation fails.

func (Database) SaveCommitSig

func (db Database) SaveCommitSig(height int64, pc tmtypes.CommitSig, votingPower, proposerPriority int64) error

SetPreCommit stores a validator's pre-commit and returns the resulting record ID. An error is returned if the operation fails.

func (Database) SaveTx

func (db Database) SaveTx(tx *types.Tx) error

SetTx stores a transaction and returns the resulting record ID. An error is returned if the operation fails.

func (Database) SaveValidator

func (db Database) SaveValidator(addr, pk string) error

SetValidator stores a validator if it does not already exist. An error is returned if the operation fails.

Jump to

Keyboard shortcuts

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