pgstatestorage

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecQuerier

type ExecQuerier interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (commandTag pgconn.CommandTag, err error)
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

type PostgresStorage

type PostgresStorage struct {
	*pgxpool.Pool
	// contains filtered or unexported fields
}

PostgresStorage implements the Storage interface

func NewPostgresStorage

func NewPostgresStorage(cfg state.Config, db *pgxpool.Pool) *PostgresStorage

NewPostgresStorage creates a new StateDB

func (*PostgresStorage) AddBatch

func (p *PostgresStorage) AddBatch(ctx context.Context, dbBatch *state.DBBatch, dbTx pgx.Tx) error

AddBatch stores a batch

func (*PostgresStorage) AddGeneratedProof

func (p *PostgresStorage) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error

AddGeneratedProof adds a generated proof to the storage

func (*PostgresStorage) AddSequence

func (p *PostgresStorage) AddSequence(ctx context.Context, sequence state.Sequence, dbTx pgx.Tx) error

AddSequence stores the sequence information to allow the aggregator verify sequences.

func (*PostgresStorage) CheckProofContainsCompleteSequences

func (p *PostgresStorage) CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) (bool, error)

CheckProofContainsCompleteSequences checks if a recursive proof contains complete sequences

func (*PostgresStorage) CheckProofExistsForBatch

func (p *PostgresStorage) CheckProofExistsForBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (bool, error)

CheckProofExistsForBatch checks if the batch is already included in any proof

func (*PostgresStorage) CleanupGeneratedProofs

func (p *PostgresStorage) CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

CleanupGeneratedProofs deletes from the storage the generated proofs up to the specified batch number included.

func (*PostgresStorage) CleanupLockedProofs

func (p *PostgresStorage) CleanupLockedProofs(ctx context.Context, duration string, dbTx pgx.Tx) (int64, error)

CleanupLockedProofs deletes from the storage the proofs locked in generating state for more than the provided threshold.

func (*PostgresStorage) DeleteBatchesNewerThanBatchNumber

func (p *PostgresStorage) DeleteBatchesNewerThanBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

DeleteBatchesNewerThanBatchNumber deletes batches previous to the given batch number

func (*PostgresStorage) DeleteBatchesOlderThanBatchNumber

func (p *PostgresStorage) DeleteBatchesOlderThanBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) error

DeleteBatchesOlderThanBatchNumber deletes batches previous to the given batch number

func (*PostgresStorage) DeleteGeneratedProofs

func (p *PostgresStorage) DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx pgx.Tx) error

DeleteGeneratedProofs deletes from the storage the generated proofs falling inside the batch numbers range.

func (*PostgresStorage) DeleteUngeneratedProofs

func (p *PostgresStorage) DeleteUngeneratedProofs(ctx context.Context, dbTx pgx.Tx) error

DeleteUngeneratedProofs deletes ungenerated proofs. This method is meant to be use during aggregator boot-up sequence

func (*PostgresStorage) GetBatch

func (p *PostgresStorage) GetBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.DBBatch, error)

GetBatch gets a batch by a given batch number

func (*PostgresStorage) GetProofReadyToVerify

func (p *PostgresStorage) GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx pgx.Tx) (*state.Proof, error)

GetProofReadyToVerify return the proof that is ready to verify

func (*PostgresStorage) GetProofsToAggregate

func (p *PostgresStorage) GetProofsToAggregate(ctx context.Context, dbTx pgx.Tx) (*state.Proof, *state.Proof, error)

GetProofsToAggregate return the next to proof that it is possible to aggregate

func (*PostgresStorage) UpdateGeneratedProof

func (p *PostgresStorage) UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx pgx.Tx) error

UpdateGeneratedProof updates a generated proof in the storage

Jump to

Keyboard shortcuts

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