Documentation
¶
Index ¶
- Constants
- Variables
- func SelectQuery(tableName string) string
- type AggSenderSQLStorage
- func (a *AggSenderSQLStorage) DeleteCertificate(tx dbtypes.Querier, height uint64, mustDelete DeleteFlag) error
- func (a *AggSenderSQLStorage) DeleteOldCertificates(tx dbtypes.Querier, maxHeight uint64) error
- func (a *AggSenderSQLStorage) GetCertificateByHeight(height uint64) (*types.Certificate, error)
- func (a *AggSenderSQLStorage) GetCertificateHeaderByHeight(height uint64) (*types.CertificateHeader, error)
- func (a *AggSenderSQLStorage) GetCertificateHeadersByStatus(statuses []agglayertypes.CertificateStatus) ([]*types.CertificateHeader, error)
- func (a *AggSenderSQLStorage) GetLastSentCertificate() (*types.Certificate, error)
- func (a *AggSenderSQLStorage) GetLastSentCertificateHeader() (*types.CertificateHeader, error)
- func (a *AggSenderSQLStorage) GetLastSentCertificateHeaderWithProofIfInError(ctx context.Context) (*types.CertificateHeader, *types.AggchainProof, error)
- func (a *AggSenderSQLStorage) GetLastSettledCertificate() (*types.CertificateHeader, error)
- func (a *AggSenderSQLStorage) GetNonAcceptedCertificate() (*NonAcceptedCertificate, error)
- func (a *AggSenderSQLStorage) MoveCertificateToHistory(tx dbtypes.Querier, height uint64) error
- func (a *AggSenderSQLStorage) SaveLastSentCertificate(ctx context.Context, certificate types.Certificate) error
- func (a *AggSenderSQLStorage) SaveNonAcceptedCertificate(ctx context.Context, nonAcceptedCert *NonAcceptedCertificate) error
- func (a *AggSenderSQLStorage) SaveOrUpdateCertificate(ctx context.Context, certificate types.Certificate) error
- func (a *AggSenderSQLStorage) UpdateCertificateStatus(ctx context.Context, certificateID common.Hash, ...) error
- type AggSenderSQLStorageConfig
- type AggSenderStorage
- type AggSenderStorageMaintainer
- type AggchainProofMeddler
- type CertificateKey
- type DeleteFlag
- type NonAcceptedCertificate
- type RuntimeData
- type StorageRetainCertificatesPolicier
- type StorageRetainCertificatesPolicy
Constants ¶
const (
KeepAllCertificates = uint32(0)
)
const (
PrefixFilename = "@"
)
Variables ¶
var (
ErrNoCertDeleted = errors.New("no certificates deleted")
)
Functions ¶
func SelectQuery ¶ added in v0.4.0
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(tx dbtypes.Querier, height uint64, mustDelete DeleteFlag) error
Delete from certificate_info and certificate_info_history the certificate CertificateKey if you don't need a tx just pass nil It required to be in certificate_info table, if not found it returns ErrNoCertDeleted error
func (*AggSenderSQLStorage) DeleteOldCertificates ¶ added in v0.7.0
func (a *AggSenderSQLStorage) DeleteOldCertificates(tx dbtypes.Querier, maxHeight uint64) error
Delete from certificate_info and certificate_info_history all certificates older than maxHeight
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) MoveCertificateToHistory ¶ added in v0.7.0
func (a *AggSenderSQLStorage) MoveCertificateToHistory(tx dbtypes.Querier, height uint64) error
Move to certificate_info_history the certificate identified by CertificateKey
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
RetainCertificatesPolicy StorageRetainCertificatesPolicy
}
AggSenderSQLStorageConfig is the configuration for the AggSenderSQLStorage
type AggSenderStorage ¶
type AggSenderStorage interface {
AggSenderStorageMaintainer
// 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
// 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 AggSenderStorageMaintainer ¶ added in v0.7.0
type AggSenderStorageMaintainer interface {
// Move to certificate_info_history the certificate identified by CertificateKey
MoveCertificateToHistory(tx dbtypes.Querier, height uint64) error
// Delete from certificate_info and certificate_info_history the certificate identified by CertificateKey
DeleteCertificate(tx dbtypes.Querier, height uint64, mustDelete DeleteFlag) error
// Delete from certificate_info and certificate_info_history all certificates older than olderThanHeight
DeleteOldCertificates(tx dbtypes.Querier, olderThanHeight uint64) error
}
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 CertificateKey ¶ added in v0.7.0
type CertificateKey struct {
Height uint64 `meddler:"height"`
RetryCount int `meddler:"retry_count"`
}
func (CertificateKey) IsRetry ¶ added in v0.7.0
func (c CertificateKey) IsRetry() bool
func (CertificateKey) String ¶ added in v0.7.0
func (c CertificateKey) String() string
type DeleteFlag ¶ added in v0.7.0
type DeleteFlag = bool
const ( MustDelete DeleteFlag = true // the delete action must affect at least one row MaybeDelete DeleteFlag = false // the delete action may affect zero rows )
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
type StorageRetainCertificatesPolicier ¶ added in v0.7.0
type StorageRetainCertificatesPolicier interface {
OnNewCert(tx dbtypes.Querier, storage AggSenderStorageMaintainer, certKey CertificateKey) error
}
type StorageRetainCertificatesPolicy ¶ added in v0.7.0
type StorageRetainCertificatesPolicy struct {
RetainCertificatesCount uint32 `mapstructure:"RetainCertificatesCount"` // 0 = retain all certificates
KeepCertificatesHistory bool `mapstructure:"KeepCertificatesHistory"`
}
func NewStorageRetainCertificatesPolicy ¶ added in v0.7.0
func NewStorageRetainCertificatesPolicy(retainCertificatesCount uint32, keepCertificatesHistory bool) *StorageRetainCertificatesPolicy
NewStorageRetainCertificatesPolicy creates a new StorageRetainCertificatesPolicy
func NewStorageRetainCertificatesPolicyDefault ¶ added in v0.7.0
func NewStorageRetainCertificatesPolicyDefault() *StorageRetainCertificatesPolicy
NewStorageRetainCertificatesPolicyDefault creates a new StorageRetainCertificatesPolicy with default values
func (*StorageRetainCertificatesPolicy) OnNewCert ¶ added in v0.7.0
func (r *StorageRetainCertificatesPolicy) OnNewCert(tx dbtypes.Querier, storage AggSenderStorageMaintainer, certKey CertificateKey) error
func (*StorageRetainCertificatesPolicy) String ¶ added in v0.7.0
func (r *StorageRetainCertificatesPolicy) String() string
func (*StorageRetainCertificatesPolicy) Validate ¶ added in v0.7.0
func (r *StorageRetainCertificatesPolicy) Validate() error