sync

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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.

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.

Jump to

Keyboard shortcuts

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