subscriptions

package
v2.12.1-mercury06192024 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidParameters = errors.New("invalid parameters provided to create a subscription contract ORM")
)
View Source
var ErrUserHasNoSubscription = errors.New("user has no subscriptions")

Functions

This section is empty.

Types

type ORM

type ORM interface {
	GetSubscriptions(ctx context.Context, offset, limit uint) ([]StoredSubscription, error)
	UpsertSubscription(ctx context.Context, subscription StoredSubscription) error
}

func NewORM

func NewORM(ds sqlutil.DataSource, lggr logger.Logger, routerContractAddress common.Address) (ORM, error)

type OnchainSubscriptions

type OnchainSubscriptions interface {
	job.ServiceCtx

	// GetMaxUserBalance returns a maximum subscription balance (juels), or error if user has no subscriptions.
	GetMaxUserBalance(common.Address) (*big.Int, error)
}

OnchainSubscriptions maintains a mirror of all subscriptions fetched from the blockchain (EVM-only). All methods are thread-safe.

func NewOnchainSubscriptions

func NewOnchainSubscriptions(client evmclient.Client, config OnchainSubscriptionsConfig, orm ORM, lggr logger.Logger) (OnchainSubscriptions, error)

type OnchainSubscriptionsConfig

type OnchainSubscriptionsConfig struct {
	ContractAddress    common.Address `json:"contractAddress"`
	BlockConfirmations uint           `json:"blockConfirmations"`
	UpdateFrequencySec uint           `json:"updateFrequencySec"`
	UpdateTimeoutSec   uint           `json:"updateTimeoutSec"`
	UpdateRangeSize    uint           `json:"updateRangeSize"`
	StoreBatchSize     uint           `json:"storeBatchSize"`
}

type StoredSubscription

type StoredSubscription struct {
	SubscriptionID uint64
	functions_router.IFunctionsSubscriptionsSubscription
}

StoredSubscription is used to populate the user subscription maps from a persistent layer like postgres.

type UserSubscriptions

type UserSubscriptions interface {
	UpdateSubscription(subscriptionId uint64, subscription *functions_router.IFunctionsSubscriptionsSubscription) bool
	GetMaxUserBalance(user common.Address) (*big.Int, error)
}

func NewUserSubscriptions

func NewUserSubscriptions() UserSubscriptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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