sync

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sync provides a sync engine that maps chain events to local store CRUD operations. The engine does not run background goroutines — callers invoke HandleEvent for each event received from the pubsub bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackoffDelay

func BackoffDelay(attempt int) time.Duration

BackoffDelay returns the reconnection delay for the given attempt per SPEC §6.5. Uses exponential backoff with jitter: 1s, 2s, 4s, 8s, 16s, 32s, 60s cap.

Types

type Engine

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

Engine processes chain events and persists them to the local store.

func New

func New(s store.Store, trackedAccounts []string) *Engine

New creates a sync engine that processes events for the given tracked accounts.

func (*Engine) HandleEvent

func (e *Engine) HandleEvent(ctx context.Context, ev interface{}) error

HandleEvent processes a single chain event via type-switch. Events for owners not in the tracked set are silently ignored. Unknown event types are also ignored (no error).

func (*Engine) Reconcile

func (e *Engine) Reconcile(ctx context.Context, q Querier) error

Reconcile performs startup reconciliation per SPEC §6.4. On first launch (no SyncState), it does a full reconciliation. On subsequent launches, it checks the block gap and either does a full reconciliation (gap > 1000) or updates the sync state.

func (*Engine) ReconcileNow added in v0.0.4

func (e *Engine) ReconcileNow(ctx context.Context, q Querier) (ReconcileStats, error)

ReconcileNow performs the full reconciliation of SPEC §6.4 unconditionally and reports what it wrote. It backs `akt store sync` (SPEC §2.5): a user who asks for a sync is asking for chain state to be re-read, not for the block gap to be consulted.

type Querier

type Querier interface {
	CurrentHeight(ctx context.Context) (int64, error)
	Deployments(ctx context.Context, owner string) ([]*store.DeploymentRecord, error)
	Leases(ctx context.Context, owner string, dseq uint64) ([]*store.LeaseRecord, error)
	Bids(ctx context.Context, owner string, dseq uint64) ([]*store.BidRecord, error)
}

Querier abstracts the chain queries needed for reconciliation. Implementations typically wrap the chain-sdk query clients.

func NewChainQuerier added in v0.0.4

func NewChainQuerier(cl aclient.LightClient) Querier

NewChainQuerier returns the Querier that reconciliation (SPEC §6.4) uses to read on-chain state through an Akash node client. Only queries are needed, so a LightClient suffices and no keyring or signer is involved.

type ReconcileStats added in v0.0.4

type ReconcileStats struct {
	Accounts    int
	Deployments int
	Leases      int
	Bids        int
	Height      int64
}

ReconcileStats counts what a reconciliation wrote. `akt store sync` reports it so the user can tell "nothing was found" apart from "nothing ran".

Jump to

Keyboard shortcuts

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