repository

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInsertRow = errors.New("unable to insert row")
	ErrUpdateRow = errors.New("unable to update row")
	ErrCopyFrom  = errors.New("unable to COPY FROM")

	ErrBeginTx  = errors.New("unable to begin transaction")
	ErrCommitTx = errors.New("unable to commit transaction")
)

Functions

func ValidateSchema

func ValidateSchema(endpoint string) error

func ValidateSchemaWithRetry

func ValidateSchemaWithRetry(endpoint string, maxRetries int, delay time.Duration) error

FIXME: improve this

Types

type Database

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

func Connect

func Connect(
	ctx context.Context,
	postgresEndpoint string,
) (*Database, error)

func (*Database) Close

func (pg *Database) Close()

func (*Database) GetAllApplications

func (pg *Database) GetAllApplications(
	ctx context.Context,
) ([]Application, error)

func (*Database) GetAllRunningApplications

func (pg *Database) GetAllRunningApplications(
	ctx context.Context,
) ([]Application, error)

GetAllRunningApplications returns a slice with the applications being actively handled by the node.

func (*Database) GetApplication

func (pg *Database) GetApplication(
	ctx context.Context,
	appAddressKey Address,
) (*Application, error)

func (*Database) GetDB

func (pg *Database) GetDB() *pgxpool.Pool

func (*Database) GetEpoch

func (pg *Database) GetEpoch(
	ctx context.Context,
	indexKey uint64,
	appAddressKey Address,
) (*Epoch, error)

func (*Database) GetEpochs

func (pg *Database) GetEpochs(ctx context.Context, application Address) ([]Epoch, error)

func (*Database) GetEspressoNonce

func (pg *Database) GetEspressoNonce(
	ctx context.Context,
	senderAddress Address,
	applicationAddress Address,
) (uint64, error)

func (*Database) GetInput

func (pg *Database) GetInput(
	ctx context.Context,
	appAddressKey Address,
	indexKey uint64,
) (*Input, error)

func (*Database) GetInputIndex

func (pg *Database) GetInputIndex(
	ctx context.Context,
	applicationAddress Address,
) (uint64, error)

func (*Database) GetInputs

func (pg *Database) GetInputs(
	ctx context.Context,
	app Address,
) ([]*Input, error)

func (*Database) GetLastProcessedBlock

func (pg *Database) GetLastProcessedBlock(
	ctx context.Context,
	appAddress Address,
) (uint64, error)

func (*Database) GetNodeConfig

func (pg *Database) GetNodeConfig(
	ctx context.Context,
) (*NodePersistentConfig, error)

func (*Database) GetOutput

func (pg *Database) GetOutput(
	ctx context.Context,
	appAddressKey Address,
	indexKey uint64,
) (*Output, error)

func (*Database) GetOutputs

func (pg *Database) GetOutputs(
	ctx context.Context,
	application Address,
) ([]Output, error)

func (*Database) GetOutputsByInputIndex

func (pg *Database) GetOutputsByInputIndex(
	ctx context.Context,
	application Address,
	inputIndex uint64,
) ([]Output, error)

func (*Database) GetPreviousEpochsWithOpenClaims

func (pg *Database) GetPreviousEpochsWithOpenClaims(
	ctx context.Context,
	app Address,
	block uint64,
) ([]*Epoch, error)

GetPreviousEpochsWithOpenClaims retrieves all Epochs that have EpochStatusClaimSubmitted status and LastBlock less than 'block'

func (*Database) GetReport

func (pg *Database) GetReport(
	ctx context.Context,
	appAddressKey Address,
	indexKey uint64,
) (*Report, error)

func (*Database) GetReports

func (pg *Database) GetReports(
	ctx context.Context,
	appAddressKey Address,
) ([]Report, error)

func (*Database) GetReportsByInputIndex

func (pg *Database) GetReportsByInputIndex(
	ctx context.Context,
	appAddressKey Address,
	inputIndex uint64,
) ([]Report, error)

func (*Database) GetSnapshot

func (pg *Database) GetSnapshot(
	ctx context.Context,
	inputIndexKey uint64,
	appAddressKey Address,
) (*Snapshot, error)

func (*Database) InsertApplication

func (pg *Database) InsertApplication(
	ctx context.Context,
	app *Application,
) (uint64, error)

func (*Database) InsertEpoch

func (pg *Database) InsertEpoch(
	ctx context.Context,
	epoch *Epoch,
) (uint64, error)

func (*Database) InsertInput

func (pg *Database) InsertInput(
	ctx context.Context,
	input *Input,
) (uint64, error)

func (*Database) InsertNodeConfig

func (pg *Database) InsertNodeConfig(
	ctx context.Context,
	config *NodePersistentConfig,
) error

func (*Database) InsertOutput

func (pg *Database) InsertOutput(
	ctx context.Context,
	output *Output,
) (uint64, error)

func (*Database) InsertReport

func (pg *Database) InsertReport(
	ctx context.Context,
	report *Report,
) error

func (*Database) InsertSnapshot

func (pg *Database) InsertSnapshot(
	ctx context.Context,
	snapshot *Snapshot,
) (id uint64, _ error)

func (*Database) StoreEpochAndInputsTransaction

func (pg *Database) StoreEpochAndInputsTransaction(
	ctx context.Context,
	epochInputsMap map[*Epoch][]Input,
	blockNumber uint64,
	contractAddress Address,
) (epochIndexIdMap map[uint64]uint64, epochIndexInputIdsMap map[uint64][]uint64, _ error)

This method should be called at the end of EVMReader read input cycle In a single transaction it updates or inserts epochs, insert inputs related to each epoch and also updates the last processed block

func (*Database) UpdateApplicationStatus

func (pg *Database) UpdateApplicationStatus(
	ctx context.Context,
	appAddressKey Address,
	newStatus ApplicationStatus,
) error

func (*Database) UpdateEpochs

func (pg *Database) UpdateEpochs(
	ctx context.Context,
	app Address,
	claims []*Epoch,
	lastClaimCheckBlock uint64,
) error

UpdateEpochs update given Epochs status and given application LastClaimCheckBlockNumber on a single transaction

func (*Database) UpdateEspressoNonce

func (pg *Database) UpdateEspressoNonce(
	ctx context.Context,
	senderAddress Address,
	applicationAddress Address,
) error

func (*Database) UpdateInputIndex

func (pg *Database) UpdateInputIndex(
	ctx context.Context,
	applicationAddress Address,
) error

func (*Database) UpdateOutputExecutionTransaction

func (pg *Database) UpdateOutputExecutionTransaction(
	ctx context.Context,
	app Address,
	executedOutputs []*Output,
	blockNumber uint64,
) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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