postgres

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const GetBlockForTimeQuery = `` /* 193-byte string literal not displayed */
View Source
const NumberOfTxFields = 21

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

Driver is postgres database driver implementation

func NewDriver

func NewDriver(ctx context.Context, db *sql.DB) *Driver

NewDriver is Driver constructor

func (*Driver) BlockContinuityCheck

func (d *Driver) BlockContinuityCheck(ctx context.Context, blx structs.BlockWithMeta, startHeight, endHeight uint64) ([][2]uint64, error)

BlockContinuityCheck check data consistency between given ranges in network / chain

func (*Driver) BlockTransactionCheck

func (d *Driver) BlockTransactionCheck(ctx context.Context, blx structs.BlockWithMeta, startHeight, endHeight uint64) ([]uint64, error)

BlockTransactionCheck check if every block has correct, corresponding number of transactions

func (*Driver) Flush

func (d *Driver) Flush() error

Flush contents of buffers to database

func (*Driver) GetBlockForTime added in v0.1.2

func (d *Driver) GetBlockForTime(ctx context.Context, blx structs.BlockWithMeta, time time.Time) (out structs.Block, isBefore bool, err error)

GetBlockForTime returns first block that comes on or after given time. If no such block exists, returns closest block that comes before given time.

func (*Driver) GetBlocksHeightsWithNumTx added in v0.0.2

func (d *Driver) GetBlocksHeightsWithNumTx(ctx context.Context, blx structs.BlockWithMeta, startHeight, endHeight uint64) ([][2]uint64, error)

GetBlocksHeightsWithNumTx gets heights and number of transactions for each block in range

func (*Driver) GetLatestBlock

func (d *Driver) GetLatestBlock(ctx context.Context, blx structs.BlockWithMeta) (out structs.Block, err error)

GetLatestBlock gets latest block

func (*Driver) GetLatestTransaction

func (d *Driver) GetLatestTransaction(ctx context.Context, in structs.TransactionWithMeta) (out structs.Transaction, err error)

GetLatestTransaction gets latest transaction from database

func (*Driver) GetTransactions

func (d *Driver) GetTransactions(ctx context.Context, tsearch params.TransactionSearch) (txs []structs.Transaction, err error)

GetTransactions gets transactions based on given criteria the order is forced to be time DESC

func (*Driver) GetTransactionsHeightsWithTxCount added in v0.0.2

func (d *Driver) GetTransactionsHeightsWithTxCount(ctx context.Context, blx structs.BlockWithMeta, startHeight, endHeight uint64) ([][2]uint64, error)

GetTransactionsHeightsWithTxCount gets the count of transaction groupped by heights

func (*Driver) StoreBlock

func (d *Driver) StoreBlock(bl structs.BlockWithMeta) error

StoreBlock appends data to buffer

func (*Driver) StoreTransaction

func (d *Driver) StoreTransaction(tx structs.TransactionWithMeta) error

StoreTransaction adds transaction to storage buffer

func (*Driver) StoreTransactions

func (d *Driver) StoreTransactions(txs []structs.TransactionWithMeta) error

StoreTransactions adds transactions to storage buffer

type ValuesPool

type ValuesPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ValuesPool is Pool of fixed size slices of interface{}

func NewValuesPool

func NewValuesPool(count, fields, size int) *ValuesPool

NewValuesPool is ValuesPool constructor

func (*ValuesPool) Get

func (vp *ValuesPool) Get() []interface{}

Get from pool or create new one

func (*ValuesPool) Put

func (vp *ValuesPool) Put(val []interface{})

Put back to the pool or discard

Jump to

Keyboard shortcuts

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