pushwatcher

package
v0.0.48 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package pushwatcher provides a client for listening to Push Chain events.

Index

Constants

View Source
const DefaultPollInterval = 2 * time.Second

Variables

View Source
var (
	ErrNilClient      = errors.New("push client is nil")
	ErrNilDatabase    = errors.New("database is nil")
	ErrAlreadyRunning = errors.New("event listener is already running")
	ErrNotRunning     = errors.New("event listener is not running")
)

Functions

This section is empty.

Types

type ChainResolver added in v0.0.45

type ChainResolver interface {
	GetClient(chainID string) (common.ChainClient, error)
}

ChainResolver resolves a CAIP-2 chain ID to its chain client. Satisfied by externalchains.Chains.

type Client

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

Client implements the ChainClient interface for Push chain

func NewClient

func NewClient(
	database *db.DB,
	chainConfig *config.ChainSpecificConfig,
	pushCore *pushcore.Client,
	chainID string,
	logger zerolog.Logger,
	pushSigner *pushsigner.Signer,
	chainResolver ChainResolver,
) (*Client, error)

NewClient creates a new Push chain client. pushSigner and chainResolver may be nil; the READ_REQUEST handler is only registered when both are present.

func (*Client) IsHealthy

func (c *Client) IsHealthy() bool

IsHealthy checks if the Push chain RPC Client is healthy

func (*Client) Start

func (c *Client) Start(ctx context.Context) error

Start initializes and starts the Push chain client

func (*Client) Stop

func (c *Client) Stop() error

Stop gracefully shuts down the Push chain client

type Config

type Config struct {
	PollInterval time.Duration
}

Config holds configuration for the Push event listener.

type EventHandler added in v0.0.45

type EventHandler interface {
	HandleEvent(ctx context.Context, event *store.Event) error
}

EventHandler processes one CONFIRMED push chain event of a registered type. Handlers own the event's status transitions; a returned error is logged and the event is retried next tick.

type EventListener

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

EventListener polls Push chain for active TSS events, pending outbounds and pending read requests via gRPC, converts them to store.Events, and inserts them into the local DB.

func NewEventListener

func NewEventListener(
	pushCore *pushcore.Client,
	database *db.DB,
	logger zerolog.Logger,
	chainConfig *config.ChainSpecificConfig,
) (*EventListener, error)

NewEventListener creates a new Push event listener.

func (*EventListener) IsRunning

func (el *EventListener) IsRunning() bool

IsRunning returns whether the event listener is currently running.

func (*EventListener) Start

func (el *EventListener) Start(ctx context.Context) error

Start begins polling for Push chain events.

func (*EventListener) Stop

func (el *EventListener) Stop() error

Stop gracefully stops the event listener.

type EventProcessor added in v0.0.45

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

EventProcessor drains CONFIRMED events from the push chain DB and dispatches them to the handler registered for their type. Event types without a handler are ignored (e.g. TSS events, which are consumed by the TSS subsystem).

func NewEventProcessor added in v0.0.45

func NewEventProcessor(
	database *db.DB,
	pollInterval time.Duration,
	logger zerolog.Logger,
) (*EventProcessor, error)

NewEventProcessor creates a new push event processor. Register handlers before Start.

func (*EventProcessor) RegisterHandler added in v0.0.45

func (p *EventProcessor) RegisterHandler(eventType string, handler EventHandler)

RegisterHandler registers a handler for an event type. Must be called before Start.

func (*EventProcessor) Start added in v0.0.45

func (p *EventProcessor) Start(ctx context.Context) error

Start begins processing events.

func (*EventProcessor) Stop added in v0.0.45

func (p *EventProcessor) Stop() error

Stop gracefully stops the processor.

type ReadEventProcessor added in v0.0.45

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

ReadEventProcessor handles READ_REQUEST events: it executes each request on its destination chain via the resolved read handler and votes the result. Transient failures (destination not served, RPC errors, vote failure) keep the event CONFIRMED for retry; corrupt events flip to REVERTED. Expiry is core's job: expired requests leave the pending query.

func NewReadEventProcessor added in v0.0.45

func NewReadEventProcessor(
	voter readVoter,
	resolver ChainResolver,
	web2Handler common.ReadRequestHandler,
	database *db.DB,
	logger zerolog.Logger,
) (*ReadEventProcessor, error)

NewReadEventProcessor creates the handler for READ_REQUEST events. web2Handler serves web2 destinations; nil means web2 reads are not served.

func (*ReadEventProcessor) HandleEvent added in v0.0.45

func (p *ReadEventProcessor) HandleEvent(ctx context.Context, event *store.Event) error

HandleEvent implements EventHandler for READ_REQUEST events.

Jump to

Keyboard shortcuts

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