postgresdriver

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 14 Imported by: 4

Documentation

Overview

Package postgresdriver is the implementation of Writer interface for the Indexer using postgres SQL as persistance

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPreviousHeight error when no previous height is stored
	ErrNoPreviousHeight = errors.New("no previous height stored")
	// ErrInvalidAddress error when given address is invalid
	ErrInvalidAddress = errors.New("invalid address")
)
View Source
var (
	// ErrByteTypeAssertionFailed error when []byte type assertion fails
	ErrByteTypeAssertionFailed = errors.New("type assertion to []byte failed")
)

Functions

This section is empty.

Types

type PostgresDriver

type PostgresDriver struct {
	*sqlx.DB
}

PostgresDriver struct handler for PostgresDB related functions

func NewPostgresDriverFromConnectionString

func NewPostgresDriverFromConnectionString(connectionString string) (*PostgresDriver, error)

NewPostgresDriverFromConnectionString returns PostgresDriver instance from connection string

func NewPostgresDriverFromSQLDBInstance

func NewPostgresDriverFromSQLDBInstance(db *sql.DB) *PostgresDriver

NewPostgresDriverFromSQLDBInstance returns PostgresDriver instance from sdl.DB instance mostly used for mocking tests

func (*PostgresDriver) GetAccountsQuantity added in v0.3.0

func (d *PostgresDriver) GetAccountsQuantity(options *types.GetAccountsQuantityOptions) (int64, error)

GetAccountsQuantity returns quantity of accounts with given height saved default height is last height

func (*PostgresDriver) GetAppsQuantity added in v0.3.0

func (d *PostgresDriver) GetAppsQuantity(options *types.GetAppsQuantityOptions) (int64, error)

GetAppsQuantity returns quantity of apps with given height saved default height is last height

func (*PostgresDriver) GetBlocksQuantity added in v0.2.0

func (d *PostgresDriver) GetBlocksQuantity() (int64, error)

GetBlocksQuantity returns quantity of blocks saved

func (*PostgresDriver) GetMaxHeightInBlocks added in v0.1.1

func (d *PostgresDriver) GetMaxHeightInBlocks() (int64, error)

GetMaxHeightInBlocks returns max height saved on blocks' table

func (*PostgresDriver) GetNodesQuantity added in v0.3.0

func (d *PostgresDriver) GetNodesQuantity(options *types.GetNodesQuantityOptions) (int64, error)

GetNodesQuantity returns quantity of nodes with given height saved default height is last height

func (*PostgresDriver) GetTransactionsQuantity added in v0.2.0

func (d *PostgresDriver) GetTransactionsQuantity() (int64, error)

GetTransactionsQuantity returns quantity of transactions saved

func (*PostgresDriver) GetTransactionsQuantityByAddress added in v0.2.0

func (d *PostgresDriver) GetTransactionsQuantityByAddress(address string) (int64, error)

GetTransactionsQuantityByAddress returns quantity of transactions with given address saved

func (*PostgresDriver) GetTransactionsQuantityByHeight added in v0.2.0

func (d *PostgresDriver) GetTransactionsQuantityByHeight(height int) (int64, error)

GetTransactionsQuantityByHeight returns quantity of transactions with given height saved height 0 is last height

func (*PostgresDriver) ReadAccountByAddress added in v0.3.0

func (d *PostgresDriver) ReadAccountByAddress(address string, options *types.ReadAccountByAddressOptions) (*types.Account, error)

ReadAccountByAddress returns an account in the database with given address

func (*PostgresDriver) ReadAccounts added in v0.3.0

func (d *PostgresDriver) ReadAccounts(options *types.ReadAccountsOptions) ([]*types.Account, error)

ReadAccounts returns accounts with given height Optional values defaults: page: 1, perPage: 1000, height: last height

func (*PostgresDriver) ReadAppByAddress added in v0.3.0

func (d *PostgresDriver) ReadAppByAddress(address string, options *types.ReadAppByAddressOptions) (*types.App, error)

ReadAppByAddress returns an app in the database with given address

func (*PostgresDriver) ReadApps added in v0.3.0

func (d *PostgresDriver) ReadApps(options *types.ReadAppsOptions) ([]*types.App, error)

ReadApps returns apps with given height Optional values defaults: page: 1, perPage: 1000

func (*PostgresDriver) ReadBlockByHash added in v0.2.0

func (d *PostgresDriver) ReadBlockByHash(hash string) (*types.Block, error)

ReadBlockByHash returns block in the database with given block hash

func (*PostgresDriver) ReadBlockByHeight added in v0.2.0

func (d *PostgresDriver) ReadBlockByHeight(height int) (*types.Block, error)

ReadBlockByHeight returns block in the database with given height height 0 is last height

func (*PostgresDriver) ReadBlocks

func (d *PostgresDriver) ReadBlocks(options *types.ReadBlocksOptions) ([]*types.Block, error)

ReadBlocks returns all blocks on the database with pagination Optional values defaults: page: 1, perPage: 1000

func (*PostgresDriver) ReadNodeByAddress added in v0.3.0

func (d *PostgresDriver) ReadNodeByAddress(address string, options *types.ReadNodeByAddressOptions) (*types.Node, error)

ReadNodeByAddress returns a node in the database with given address

func (*PostgresDriver) ReadNodes added in v0.3.0

func (d *PostgresDriver) ReadNodes(options *types.ReadNodesOptions) ([]*types.Node, error)

ReadNodes returns nodes with given height Optional values defaults: page: 1, perPage: 1000, height: last height

func (*PostgresDriver) ReadTransactionByHash added in v0.2.0

func (d *PostgresDriver) ReadTransactionByHash(hash string) (*types.Transaction, error)

ReadTransactionByHash returns transaction in the database with given transaction hash

func (*PostgresDriver) ReadTransactions

func (d *PostgresDriver) ReadTransactions(options *types.ReadTransactionsOptions) ([]*types.Transaction, error)

ReadTransactions returns transactions on the database with pagination Optional values defaults: page: 1, perPage: 1000

func (*PostgresDriver) ReadTransactionsByAddress added in v0.1.3

func (d *PostgresDriver) ReadTransactionsByAddress(address string, options *types.ReadTransactionsByAddressOptions) ([]*types.Transaction, error)

ReadTransactionsByAddress returns transactions with given from address Optional values defaults: page: 1, perPage: 1000

func (*PostgresDriver) ReadTransactionsByHeight added in v0.2.0

func (d *PostgresDriver) ReadTransactionsByHeight(height int, options *types.ReadTransactionsByHeightOptions) ([]*types.Transaction, error)

ReadTransactionsByHeight returns transactions with given height height 0 is last height Optional values defaults: page: 1, perPage: 1000

func (*PostgresDriver) WriteAccounts added in v0.5.0

func (d *PostgresDriver) WriteAccounts(accounts []*types.Account) error

WriteAccounts inserts given accounts to the database

func (*PostgresDriver) WriteApps added in v0.3.0

func (d *PostgresDriver) WriteApps(apps []*types.App) error

WriteApps inserts given apps to the database

func (*PostgresDriver) WriteBlock

func (d *PostgresDriver) WriteBlock(block *types.Block) error

WriteBlock inserts given block to the database

func (*PostgresDriver) WriteBlockCalculatedFields added in v0.6.1

func (d *PostgresDriver) WriteBlockCalculatedFields(block *types.Block) error

WriteBlockCalculatedFields writes block calculated fields (quantities and took)

func (*PostgresDriver) WriteNodes added in v0.3.0

func (d *PostgresDriver) WriteNodes(nodes []*types.Node) error

WriteNodes inserts given nodes to the database

func (*PostgresDriver) WriteTransactions

func (d *PostgresDriver) WriteTransactions(txs []*types.Transaction) error

WriteTransactions inserts given transactions to the database

Jump to

Keyboard shortcuts

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