pgpoolstorage

package
v0.0.2-RC1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound indicates an object has not been found for the search criteria used
	ErrNotFound = errors.New("object not found")
)

Functions

This section is empty.

Types

type PostgresPoolStorage

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

PostgresPoolStorage is an implementation of the Pool interface that uses a postgres database to store the data

func NewPostgresPoolStorage

func NewPostgresPoolStorage(cfg db.Config) (*PostgresPoolStorage, error)

NewPostgresPoolStorage creates and initializes an instance of PostgresPoolStorage

func (*PostgresPoolStorage) AddTx

AddTx adds a transaction to the pool table with the provided status

func (*PostgresPoolStorage) CountTransactionsByStatus

func (p *PostgresPoolStorage) CountTransactionsByStatus(ctx context.Context, status pool.TxStatus) (uint64, error)

CountTransactionsByStatus get number of transactions accordingly to the provided status

func (*PostgresPoolStorage) DeleteTxsByHashes

func (p *PostgresPoolStorage) DeleteTxsByHashes(ctx context.Context, hashes []common.Hash) error

DeleteTxsByHashes deletes txs by their hashes

func (*PostgresPoolStorage) GetGasPrice

func (p *PostgresPoolStorage) GetGasPrice(ctx context.Context) (uint64, error)

GetGasPrice returns the current gas price

func (*PostgresPoolStorage) GetNonce

func (p *PostgresPoolStorage) GetNonce(ctx context.Context, address common.Address) (uint64, error)

GetNonce gets the nonce to the provided address accordingly to the txs in the pool

func (*PostgresPoolStorage) GetPendingTxHashesSince

func (p *PostgresPoolStorage) GetPendingTxHashesSince(ctx context.Context, since time.Time) ([]common.Hash, error)

GetPendingTxHashesSince returns the pending tx since the given time.

func (*PostgresPoolStorage) GetTxByHash

func (p *PostgresPoolStorage) GetTxByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)

GetTxByHash gets a transaction in the pool by its hash

func (*PostgresPoolStorage) GetTxFromAddressFromByHash

func (p *PostgresPoolStorage) GetTxFromAddressFromByHash(ctx context.Context, hash common.Hash) (common.Address, uint64, error)

GetTxFromAddressFromByHash gets tx from address by hash

func (*PostgresPoolStorage) GetTxs

func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxStatus, isClaims bool, minGasPrice, limit uint64) ([]*pool.Transaction, error)

GetTxs gets txs with the lowest nonce

func (*PostgresPoolStorage) GetTxsByFromAndNonce

func (p *PostgresPoolStorage) GetTxsByFromAndNonce(ctx context.Context, from common.Address, nonce uint64) ([]pool.Transaction, error)

GetTxsByFromAndNonce get all the transactions from the pool with the same from and nonce

func (*PostgresPoolStorage) GetTxsByStatus

func (p *PostgresPoolStorage) GetTxsByStatus(ctx context.Context, status pool.TxStatus, isClaims bool, limit uint64) ([]pool.Transaction, error)

GetTxsByStatus returns an array of transactions filtered by status limit parameter is used to limit amount txs from the db, if limit = 0, then there is no limit

func (*PostgresPoolStorage) IncrementFailedCounter

func (p *PostgresPoolStorage) IncrementFailedCounter(ctx context.Context, hashes []string) error

IncrementFailedCounter increment for failed txs failed counter

func (*PostgresPoolStorage) IsTxPending

func (p *PostgresPoolStorage) IsTxPending(ctx context.Context, hash common.Hash) (bool, error)

IsTxPending determines if the tx associated to the given hash is pending or not.

func (*PostgresPoolStorage) SetGasPrice

func (p *PostgresPoolStorage) SetGasPrice(ctx context.Context, gasPrice uint64) error

SetGasPrice allows an external component to define the gas price

func (*PostgresPoolStorage) UpdateTxStatus

func (p *PostgresPoolStorage) UpdateTxStatus(ctx context.Context, hash common.Hash, newStatus pool.TxStatus) error

UpdateTxStatus updates a transaction status accordingly to the provided status and hash

func (*PostgresPoolStorage) UpdateTxsStatus

func (p *PostgresPoolStorage) UpdateTxsStatus(ctx context.Context, hashes []string, newStatus pool.TxStatus) error

UpdateTxsStatus updates transactions status accordingly to the provided status and hashes

Jump to

Keyboard shortcuts

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