db

package
v0.7.0-beta9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsJSONFilePath

func IsJSONFilePath(s string) bool

IsJSONFilePath determines if the given string is likely a JSON file path by checking if it contains path separators and has a file extension

func SelectQuery added in v0.4.0

func SelectQuery(tableName string) string

SelectQuery generates a SELECT query string for the CertificateHeader fields using reflection

Types

type AggSenderSQLStorage

type AggSenderSQLStorage struct {
	dbtypes.KeyValueStorager
	// contains filtered or unexported fields
}

AggSenderSQLStorage is the struct that implements the AggSenderStorage interface

func NewAggSenderSQLStorage

func NewAggSenderSQLStorage(logger aggkitcommon.Logger, cfg AggSenderSQLStorageConfig) (*AggSenderSQLStorage, error)

NewAggSenderSQLStorage creates a new AggSenderSQLStorage

func (*AggSenderSQLStorage) DeleteCertificate

func (a *AggSenderSQLStorage) DeleteCertificate(ctx context.Context, certificateID common.Hash) error

DeleteCertificate deletes a certificate from the storage

func (*AggSenderSQLStorage) GetCertificateByHeight

func (a *AggSenderSQLStorage) GetCertificateByHeight(height uint64) (*types.Certificate, error)

GetCertificateByHeight returns a certificate by its height

func (*AggSenderSQLStorage) GetCertificateHeaderByHeight added in v0.4.0

func (a *AggSenderSQLStorage) GetCertificateHeaderByHeight(height uint64) (*types.CertificateHeader, error)

GetCertificateHeaderByHeight returns a certificate by its height

func (*AggSenderSQLStorage) GetCertificateHeadersByStatus added in v0.4.0

func (a *AggSenderSQLStorage) GetCertificateHeadersByStatus(
	statuses []agglayertypes.CertificateStatus) ([]*types.CertificateHeader, error)

GetCertificateHeadersByStatus returns a list of certificate headers by their status

func (*AggSenderSQLStorage) GetLastSentCertificate

func (a *AggSenderSQLStorage) GetLastSentCertificate() (*types.Certificate, error)

GetLastSentCertificate returns the last certificate sent to the aggLayer

func (*AggSenderSQLStorage) GetLastSentCertificateHeader added in v0.4.0

func (a *AggSenderSQLStorage) GetLastSentCertificateHeader() (*types.CertificateHeader, error)

GetLastSentCertificateHeader returns the last certificate header sent to the aggLayer

func (*AggSenderSQLStorage) GetLastSentCertificateHeaderWithProofIfInError added in v0.4.0

func (a *AggSenderSQLStorage) GetLastSentCertificateHeaderWithProofIfInError(
	ctx context.Context) (*types.CertificateHeader, *types.AggchainProof, error)

GetLastSentCertificateHeaderWithProofIfInError returns the last certificate header sent to the aggLayer and the aggchain proof if the certificate is in error

func (*AggSenderSQLStorage) GetLastSettledCertificate added in v0.7.0

func (a *AggSenderSQLStorage) GetLastSettledCertificate() (*types.CertificateHeader, error)

GetLastSettledCertificate returns the last settled certificate from the storage

func (*AggSenderSQLStorage) GetNonAcceptedCertificate added in v0.4.0

func (a *AggSenderSQLStorage) GetNonAcceptedCertificate() (*NonAcceptedCertificate, error)

GetNonAcceptedCertificates returns a list of non-accepted certificates

func (*AggSenderSQLStorage) SaveLastSentCertificate

func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certificate types.Certificate) error

SaveLastSentCertificate saves the last certificate sent to the aggLayer

func (*AggSenderSQLStorage) SaveNonAcceptedCertificate added in v0.4.0

func (a *AggSenderSQLStorage) SaveNonAcceptedCertificate(
	ctx context.Context, nonAcceptedCert *NonAcceptedCertificate) error

SaveNonAcceptedCertificate saves a non-accepted certificate in the storage in the key-value table since we are only saving the last non-accepted certificate This is used to keep track of the last non-accepted certificate and to allow for debugging and analysis of why they were not accepted.

func (*AggSenderSQLStorage) SaveOrUpdateCertificate added in v0.7.0

func (a *AggSenderSQLStorage) SaveOrUpdateCertificate(ctx context.Context, certificate types.Certificate) error

SaveOrUpdateCertificate saves the certificate in the storage It will insert a new certificate or update the existing one if it has the same height and certificate ID

func (*AggSenderSQLStorage) UpdateCertificateStatus added in v0.4.0

func (a *AggSenderSQLStorage) UpdateCertificateStatus(
	ctx context.Context,
	certificateID common.Hash,
	newStatus agglayertypes.CertificateStatus,
	updatedAt uint32) error

UpdateCertificateStatus updates a certificate status in the storage

type AggSenderSQLStorageConfig

type AggSenderSQLStorageConfig struct {
	DBPath                  string
	CertificatesDir         string
	KeepCertificatesHistory bool
}

AggSenderSQLStorageConfig is the configuration for the AggSenderSQLStorage

type AggSenderStorage

type AggSenderStorage interface {
	// GetCertificateByHeight returns a certificate by its height
	GetCertificateByHeight(height uint64) (*types.Certificate, error)
	// GetLastSentCertificate returns the last certificate sent to the aggLayer
	GetLastSentCertificate() (*types.Certificate, error)
	// SaveLastSentCertificate saves the last certificate sent to the aggLayer
	SaveLastSentCertificate(ctx context.Context, certificate types.Certificate) error
	// DeleteCertificate deletes a certificate from the storage
	DeleteCertificate(ctx context.Context, certificateID common.Hash) error
	// GetCertificateHeadersByStatus returns a list of certificate headers by their status
	GetCertificateHeadersByStatus(status []agglayertypes.CertificateStatus) ([]*types.CertificateHeader, error)
	// UpdateCertificateStatus updates certificate status in db
	UpdateCertificateStatus(
		ctx context.Context,
		certificateID common.Hash,
		newStatus agglayertypes.CertificateStatus,
		updatedAt uint32) error
	// GetLastSentCertificateHeader returns the last certificate header sent to the aggLayer
	GetLastSentCertificateHeader() (*types.CertificateHeader, error)
	// GetCertificateHeaderByHeight returns a certificate header by its height
	GetCertificateHeaderByHeight(height uint64) (*types.CertificateHeader, error)
	// GetLastSentCertificateHeaderWithProofIfInError returns the last certificate header sent to the aggLayer
	// and the aggchain proof if the certificate is in error
	GetLastSentCertificateHeaderWithProofIfInError(
		ctx context.Context) (*types.CertificateHeader, *types.AggchainProof, error)
	// SaveNonAcceptedCertificate saves a non-accepted certificate in the storage
	SaveNonAcceptedCertificate(ctx context.Context, nonAcceptedCert *NonAcceptedCertificate) error
	// GetNonAcceptedCertificate returns the last non-accepted certificate
	GetNonAcceptedCertificate() (*NonAcceptedCertificate, error)
	// SaveOrUpdateCertificate saves or updates a certificate in the storage
	SaveOrUpdateCertificate(ctx context.Context, certificate types.Certificate) error
	// GetLastSettledCertificate returns the last settled certificate from the storage
	GetLastSettledCertificate() (*types.CertificateHeader, error)
}

AggSenderStorage is the interface that defines the methods to interact with the storage

type AggchainProofMeddler added in v0.3.0

type AggchainProofMeddler struct{}

AggchainProofMeddler is a meddler.Meddler implementation for the AggchainProof type.

func (*AggchainProofMeddler) PostRead added in v0.3.0

func (m *AggchainProofMeddler) PostRead(fieldAddr interface{}, scanTarget interface{}) error

PostRead decodes the data from the database into the field.

func (*AggchainProofMeddler) PreRead added in v0.3.0

func (m *AggchainProofMeddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)

PreRead prepares the field for reading from the database.

func (*AggchainProofMeddler) PreWrite added in v0.3.0

func (m *AggchainProofMeddler) PreWrite(field interface{}) (saveValue interface{}, err error)

PreWrite prepares the field for writing to the database.

type NonAcceptedCertificate added in v0.4.0

type NonAcceptedCertificate struct {
	Height uint64 `meddler:"height"`
	// SignedCertificate is "@<file_path>" or the actual JSON content of the certificate
	SignedCertificate string `meddler:"signed_certificate"`
	CreatedAt         uint32 `meddler:"created_at"`
	// CertificateHash of the file that contains the certificate in JSON format
	CertificateHash common.Hash `meddler:"certificate_hash,hash"`
	// Error message indicating why the certificate was not accepted
	Error string `meddler:"error"`
}

func NewNonAcceptedCertificate added in v0.4.0

func NewNonAcceptedCertificate(
	cert *agglayertypes.Certificate,
	createdAt uint32,
	certError string) (*NonAcceptedCertificate, error)

type RuntimeData added in v0.2.0

type RuntimeData struct {
	NetworkID uint32
}

func (RuntimeData) IsCompatible added in v0.2.0

func (r RuntimeData) IsCompatible(storage RuntimeData) error

func (RuntimeData) String added in v0.2.0

func (r RuntimeData) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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