sqldb

package
v0.34.4 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queries added in v0.34.4

type Queries struct {
	LastBlockHeight *sqlx.NamedStmt
	SetBlockHeight  string
}

type SQLDB

type SQLDB struct {
	DB *sqlx.DB
	adapters.DBAdapter
	Schema  string
	Queries Queries
	types.SQLNames
	Log *logging.Logger
}

SQLDB implements the access to a sql database

func NewSQLDB

func NewSQLDB(connection types.SQLConnection) (*SQLDB, error)

NewSQLDB delegates work to a specific database adapter implementation, opens database connection and create log tables

func (*SQLDB) CleanTables

func (db *SQLDB) CleanTables(chainID, burrowVersion string) error

CleanTables drop tables if stored chainID is different from the given one & store new chainID if the chainID is the same, do nothing

func (*SQLDB) Close

func (db *SQLDB) Close()

Close database connection

func (*SQLDB) GetBlock

func (db *SQLDB) GetBlock(chainID string, height uint64) (types.EventData, error)

GetBlock returns all tables structures and row data for given block

func (*SQLDB) Init added in v0.34.4

func (db *SQLDB) Init(chainID, burrowVersion string) error

Initialise the system and chain tables in case this is the first run - is idempotent though will drop tables if ChainID has changed

func (*SQLDB) InitChain added in v0.34.4

func (db *SQLDB) InitChain(chainID, burrowVersion string) (chainIDChanged bool, _ error)

func (*SQLDB) LastBlockHeight added in v0.34.4

func (db *SQLDB) LastBlockHeight(chainID string) (uint64, error)

func (*SQLDB) Ping

func (db *SQLDB) Ping() error

Ping database

func (*SQLDB) RestoreDB

func (db *SQLDB) RestoreDB(restoreTime time.Time, prefix string) error

RestoreDB restores the DB to a given moment in time. If prefix is provided restores the table state to a new set of tables as <prefix>_<table name>. Drops destination tables before recreating them. If zero time passed restores all values

func (*SQLDB) SetBlock

func (db *SQLDB) SetBlock(chainID string, eventTables types.EventTables, eventData types.EventData) error

SetBlock inserts or updates multiple rows and stores log info in SQL tables

func (*SQLDB) SetBlockHeight added in v0.34.4

func (db *SQLDB) SetBlockHeight(tx sqlx.Ext, chainID string, height uint64) error

func (*SQLDB) SynchronizeDB

func (db *SQLDB) SynchronizeDB(chainID string, eventTables types.EventTables) error

SynchronizeDB synchronize db tables structures from given tables specifications

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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