Documentation
¶
Index ¶
- func ImportDataFromBridgesyncer(ctx context.Context, logger aggkitcommon.Logger, bridgeDBFilename string, ...) error
- func ImportKeyValueFromBridgesyncer(ctx context.Context, bridgeDBFilename string, claimDBFilename string, ...) error
- func New(logger aggkitcommon.Logger, database *sql.DB, ownerName string, ...) (claimsynctypes.ClaimStorager, error)
- func NewStandalone(logger aggkitcommon.Logger, dbPath string, ownerName string, ...) (claimsynctypes.ClaimStorager, error)
- type BridgeSyncerStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ImportDataFromBridgesyncer ¶
func ImportDataFromBridgesyncer(ctx context.Context, logger aggkitcommon.Logger, bridgeDBFilename string, claimDBFilename string) error
ImportDataFromBridgesyncer copies block, claim, set_claim and unset_claim data from a bridgesync SQLite database (bridgeDBFilename) into the claimsync SQLite database (claimDBFilename), creating and migrating it if it does not yet exist.
The caller is responsible for deciding whether a migration is needed (e.g. via InspectBridgeSyncer and BridgeSyncerStatus.ShouldMigrate) before calling this function. No precondition checks are performed here.
The import is atomic: data is written to a temporary file first and only renamed to claimDBFilename on success, so a crash mid-import leaves claimDBFilename absent and the migration will be retried on the next startup.
Column-level differences between bridge schema versions are handled automatically:
- block.hash - present since bridgesync migration 0003; defaults to ”.
- claim.tx_hash - present since bridgesync migration 0002; defaults to ”.
- claim.block_timestamp - present since bridgesync migration 0002; defaults to 0.
- claim.type - present since bridgesync migration 0012; defaults to ”.
func ImportKeyValueFromBridgesyncer ¶
func ImportKeyValueFromBridgesyncer( ctx context.Context, bridgeDBFilename string, claimDBFilename string, owner string) error
ImportKeyValueFromBridgesyncer copies the single key_value row from the bridgesync SQLite database (bridgeDBFilename) into the claimsync SQLite database (claimDBFilename), replacing the original owner value with the provided owner parameter.
The function is a no-op when the key_value table does not exist in the bridge DB or contains no rows. In that case the claimDB is not created at all. The import is idempotent: an existing row with the same (owner, key) is silently skipped (INSERT OR IGNORE).
func New ¶
func New( logger aggkitcommon.Logger, database *sql.DB, ownerName string, dbQueryTimeout time.Duration, ) (claimsynctypes.ClaimStorager, error)
New creates a Storage using the provided sql.DB, so it can share
func NewStandalone ¶
func NewStandalone(logger aggkitcommon.Logger, dbPath string, ownerName string, dbQueryTimeout time.Duration) (claimsynctypes.ClaimStorager, error)
NewStandalone opens (or creates) the SQLite database at dbPath, runs all pending migrations, and returns a ready-to-use Storage along with the underlying *sql.DB (needed by the processor for transaction management).
Types ¶
type BridgeSyncerStatus ¶
type BridgeSyncerStatus struct {
// BridgeDBExists reports whether the bridgesync database file exists on disk.
BridgeDBExists bool
// ClaimDBExists reports whether the claimsync database file already exists on disk.
ClaimDBExists bool
// MigrationOK reports whether requiredBridgeMigration has been applied to the
// bridge DB. Only meaningful when BridgeDBExists is true.
MigrationOK bool
// HasClaimData reports whether any of the claim, set_claim or unset_claim tables
// contain at least one row. Only meaningful when BridgeDBExists is true and the
// required tables are present.
HasClaimData bool
}
BridgeSyncerStatus holds the read-only inspection results produced by InspectBridgeSyncer. Each field is only meaningful when the fields it depends on are true (see field comments).
func InspectBridgeSyncer ¶
func InspectBridgeSyncer(ctx context.Context, bridgeDBFilename, claimDBFilename string) (BridgeSyncerStatus, error)
InspectBridgeSyncer performs a read-only inspection of the bridge and claim database files and returns a BridgeSyncerStatus summary. It never writes to either database.
func (BridgeSyncerStatus) ShouldMigrate ¶
func (s BridgeSyncerStatus) ShouldMigrate() bool
ShouldMigrate reports whether a data migration from the bridgesync DB into the claimsync DB should be performed. It returns true only when all of the following conditions hold:
- the bridge DB exists on disk,
- the claim DB does not yet exist (migration not already done),
- the required bridge migration has been applied, and
- the bridge DB contains claim data worth copying.
func (BridgeSyncerStatus) String ¶
func (s BridgeSyncerStatus) String() string
String returns a human-readable summary of the status.
func (BridgeSyncerStatus) Validate ¶
func (s BridgeSyncerStatus) Validate() error
Validate returns an error when the status indicates a blocking condition that requires user intervention. Specifically, it errors when the bridge DB contains claim data but the required bridge migration has not been applied, meaning the node must first be upgraded to an intermediate version that runs that migration.