db

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: CC0-1.0 Imports: 12 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 {
	*sql.DB
}

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

func OpenDB

func OpenDB(cfg config.Config) (*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.

func (*Database) ExportBlock

func (db *Database) ExportBlock(b *tmctypes.ResultBlock, txs []sdk.TxResponse, vals *tmctypes.ResultValidators) error

ExportBlock accepts a finalized block and a corresponding set of transactions and persists them to the database along with attributable metadata. An error is returned if the write fails.

func (*Database) ExportPreCommits

func (db *Database) ExportPreCommits(commit *tmtypes.Commit, vals *tmctypes.ResultValidators) error

ExportPreCommits accepts a block commitment and a coressponding set of validators for the commitment and persists them to the database. An error is returned if any write fails or if there is any missing aggregated data.

func (*Database) ExportValidator

func (db *Database) ExportValidator(val *tmtypes.Validator) error

ExportValidator persists a Tendermint validator with an address and a consensus public key. An error is returned if the public key cannot be Bech32 encoded or if the DB write fails.

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

func (db *Database) SetBlock(b *tmctypes.ResultBlock, tg, pc uint64) (uint64, error)

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

func (*Database) SetPreCommit

func (db *Database) SetPreCommit(pc *tmtypes.CommitSig, vp, pp int64) (uint64, error)

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

func (*Database) SetTx

func (db *Database) SetTx(tx sdk.TxResponse) (uint64, error)

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

func (*Database) SetValidator

func (db *Database) SetValidator(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