subscriptions

package
v2.10.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 19 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(offset, limit uint, qopts ...pg.QOpt) ([]StoredSubscription, error)
	UpsertSubscription(subscription StoredSubscription, qopts ...pg.QOpt) error
}

func NewORM

func NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig, 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