Documentation ¶
Index ¶
- type PostgresPoolStorage
- func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error
- func (p *PostgresPoolStorage) AddTx(ctx context.Context, tx pool.Transaction) error
- func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error)
- func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error
- func (p *PostgresPoolStorage) CountTransactionsByFromAndStatus(ctx context.Context, from common.Address, status ...pool.TxStatus) (uint64, error)
- func (p *PostgresPoolStorage) CountTransactionsByStatus(ctx context.Context, status ...pool.TxStatus) (uint64, error)
- func (p *PostgresPoolStorage) DeleteFailedTransactionsOlderThan(ctx context.Context, date time.Time) error
- func (p *PostgresPoolStorage) DeleteGasPricesHistoryOlderThan(ctx context.Context, date time.Time) error
- func (p *PostgresPoolStorage) DeleteTransactionByHash(ctx context.Context, hash common.Hash) error
- func (p *PostgresPoolStorage) DeleteTransactionsByHashes(ctx context.Context, hashes []common.Hash) error
- func (p *PostgresPoolStorage) DescribePolicies(ctx context.Context) ([]pool.Policy, error)
- func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error)
- func (p *PostgresPoolStorage) GetAllAddressesBlocked(ctx context.Context) ([]common.Address, error)
- func (p *PostgresPoolStorage) GetGasPrices(ctx context.Context) (uint64, uint64, error)
- func (p *PostgresPoolStorage) GetNonWIPPendingTxs(ctx context.Context) ([]pool.Transaction, error)
- func (p *PostgresPoolStorage) GetNonce(ctx context.Context, address common.Address) (uint64, error)
- func (p *PostgresPoolStorage) GetPendingTxHashesSince(ctx context.Context, since time.Time) ([]common.Hash, error)
- func (p *PostgresPoolStorage) GetTxByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error)
- func (p *PostgresPoolStorage) GetTxFromAddressFromByHash(ctx context.Context, hash common.Hash) (common.Address, uint64, error)
- func (p *PostgresPoolStorage) GetTxZkCountersByHash(ctx context.Context, hash common.Hash) (*state.ZKCounters, error)
- func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxStatus, minGasPrice, limit uint64) ([]*pool.Transaction, error)
- func (p *PostgresPoolStorage) GetTxsByFromAndNonce(ctx context.Context, from common.Address, nonce uint64) ([]pool.Transaction, error)
- func (p *PostgresPoolStorage) GetTxsByStatus(ctx context.Context, status pool.TxStatus, limit uint64) ([]pool.Transaction, error)
- func (p *PostgresPoolStorage) IsTxPending(ctx context.Context, hash common.Hash) (bool, error)
- func (p *PostgresPoolStorage) ListAcl(ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error)
- func (p *PostgresPoolStorage) MarkWIPTxsAsPending(ctx context.Context) error
- func (p *PostgresPoolStorage) MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
- func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error
- func (p *PostgresPoolStorage) SetGasPrices(ctx context.Context, l2GasPrice, l1GasPrice uint64) error
- func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error
- func (p *PostgresPoolStorage) UpdateTxStatus(ctx context.Context, updateInfo pool.TxStatusUpdateInfo) error
- func (p *PostgresPoolStorage) UpdateTxWIPStatus(ctx context.Context, hash common.Hash, isWIP bool) error
- func (p *PostgresPoolStorage) UpdateTxsStatus(ctx context.Context, updateInfos []pool.TxStatusUpdateInfo) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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) AddAddressesToPolicy ¶
func (p *PostgresPoolStorage) AddAddressesToPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error
AddAddressesToPolicy adds addresses to the named policy
func (*PostgresPoolStorage) AddTx ¶
func (p *PostgresPoolStorage) AddTx(ctx context.Context, tx pool.Transaction) error
AddTx adds a transaction to the pool table with the provided status
func (*PostgresPoolStorage) CheckPolicy ¶
func (p *PostgresPoolStorage) CheckPolicy(ctx context.Context, policy pool.PolicyName, address common.Address) (bool, error)
CheckPolicy returns the rule for the named policy and address. If the address is associated with the policy, the rule will be the setting for the policy. If the address is no associated with the policy, the rule will be the opposite of the policy setting.
func (*PostgresPoolStorage) ClearPolicy ¶
func (p *PostgresPoolStorage) ClearPolicy(ctx context.Context, policy pool.PolicyName) error
ClearPolicy removes _all_ addresses from the named policy
func (*PostgresPoolStorage) CountTransactionsByFromAndStatus ¶
func (p *PostgresPoolStorage) CountTransactionsByFromAndStatus(ctx context.Context, from common.Address, status ...pool.TxStatus) (uint64, error)
CountTransactionsByFromAndStatus get number of transactions accordingly to the from address and provided statuses
func (*PostgresPoolStorage) CountTransactionsByStatus ¶
func (p *PostgresPoolStorage) CountTransactionsByStatus(ctx context.Context, status ...pool.TxStatus) (uint64, error)
CountTransactionsByStatus get number of transactions accordingly to the provided statuses
func (*PostgresPoolStorage) DeleteFailedTransactionsOlderThan ¶
func (p *PostgresPoolStorage) DeleteFailedTransactionsOlderThan(ctx context.Context, date time.Time) error
DeleteFailedTransactionsOlderThan deletes all failed transactions older than the given date
func (*PostgresPoolStorage) DeleteGasPricesHistoryOlderThan ¶
func (p *PostgresPoolStorage) DeleteGasPricesHistoryOlderThan(ctx context.Context, date time.Time) error
DeleteGasPricesHistoryOlderThan deletes all gas prices older than the given date except the last one
func (*PostgresPoolStorage) DeleteTransactionByHash ¶
DeleteTransactionByHash deletes tx by its hash
func (*PostgresPoolStorage) DeleteTransactionsByHashes ¶
func (p *PostgresPoolStorage) DeleteTransactionsByHashes(ctx context.Context, hashes []common.Hash) error
DeleteTransactionsByHashes deletes txs by their hashes
func (*PostgresPoolStorage) DescribePolicies ¶
DescribePolicies return all the policies
func (*PostgresPoolStorage) DescribePolicy ¶
func (p *PostgresPoolStorage) DescribePolicy(ctx context.Context, name pool.PolicyName) (pool.Policy, error)
DescribePolicy returns the named policy
func (*PostgresPoolStorage) GetAllAddressesBlocked ¶
GetAllAddressesBlocked get all addresses blocked
func (*PostgresPoolStorage) GetGasPrices ¶
GetGasPrices returns the latest l2 and l1 gas prices
func (*PostgresPoolStorage) GetNonWIPPendingTxs ¶
func (p *PostgresPoolStorage) GetNonWIPPendingTxs(ctx context.Context) ([]pool.Transaction, error)
GetNonWIPPendingTxs returns an array of transactions
func (*PostgresPoolStorage) GetNonce ¶
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) GetTxZkCountersByHash ¶
func (p *PostgresPoolStorage) GetTxZkCountersByHash(ctx context.Context, hash common.Hash) (*state.ZKCounters, error)
GetTxZkCountersByHash gets a transaction zkcounters by its hash
func (*PostgresPoolStorage) GetTxs ¶
func (p *PostgresPoolStorage) GetTxs(ctx context.Context, filterStatus pool.TxStatus, 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, 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) IsTxPending ¶
IsTxPending determines if the tx associated to the given hash is pending or not.
func (*PostgresPoolStorage) ListAcl ¶
func (p *PostgresPoolStorage) ListAcl( ctx context.Context, policy pool.PolicyName, query []common.Address) ([]common.Address, error)
ListAcl returns a list of the addresses associated with the policy
func (*PostgresPoolStorage) MarkWIPTxsAsPending ¶
func (p *PostgresPoolStorage) MarkWIPTxsAsPending(ctx context.Context) error
MarkWIPTxsAsPending updates WIP status to non WIP
func (*PostgresPoolStorage) MinL2GasPriceSince ¶
func (p *PostgresPoolStorage) MinL2GasPriceSince(ctx context.Context, timestamp time.Time) (uint64, error)
MinL2GasPriceSince returns the min L2 gas price after given timestamp
func (*PostgresPoolStorage) RemoveAddressesFromPolicy ¶
func (p *PostgresPoolStorage) RemoveAddressesFromPolicy(ctx context.Context, policy pool.PolicyName, addresses []common.Address) error
RemoveAddressesFromPolicy removes addresses from the named policy
func (*PostgresPoolStorage) SetGasPrices ¶
func (p *PostgresPoolStorage) SetGasPrices(ctx context.Context, l2GasPrice, l1GasPrice uint64) error
SetGasPrices sets the latest l2 and l1 gas prices
func (*PostgresPoolStorage) UpdatePolicy ¶
func (p *PostgresPoolStorage) UpdatePolicy(ctx context.Context, policy pool.PolicyName, allow bool) error
UpdatePolicy sets the allow/deny rule for the named policy
func (*PostgresPoolStorage) UpdateTxStatus ¶
func (p *PostgresPoolStorage) UpdateTxStatus(ctx context.Context, updateInfo pool.TxStatusUpdateInfo) error
UpdateTxStatus updates a transaction status accordingly to the provided status and hash
func (*PostgresPoolStorage) UpdateTxWIPStatus ¶
func (p *PostgresPoolStorage) UpdateTxWIPStatus(ctx context.Context, hash common.Hash, isWIP bool) error
UpdateTxWIPStatus updates a transaction wip status accordingly to the provided WIP status and hash
func (*PostgresPoolStorage) UpdateTxsStatus ¶
func (p *PostgresPoolStorage) UpdateTxsStatus(ctx context.Context, updateInfos []pool.TxStatusUpdateInfo) error
UpdateTxsStatus updates transactions status accordingly to the provided status and hashes