kernels

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingStart         = errors.New("must have either startBlock or startTime")
	ErrNegativeRate         = errors.New("earn rate must be non-negative")
	ErrInvalidUserAddr      = errors.New("invalid user address")
	ErrEmptySource          = errors.New("source cannot be empty")
	ErrEmptySubSource       = errors.New("subSource cannot be empty")
	ErrEmptyCategory        = errors.New("category cannot be empty")
	ErrNegativeAmount       = errors.New("amount must be positive")
	ErrMissingGrantTime     = errors.New("grant time must be set")
	ErrEarnInf              = errors.New("earn rate cannot be infinite")
	ErrNonPostiveMultiplier = errors.New("multiplier must be positive")
	ErrNonPostiveStartBlock = errors.New("start block must be positive")
	ErrNonPostiveStartTime  = errors.New("start time must be positive")
	ErrInvalidEarnRate      = errors.New("invalid earn rate")
	ErrEmptyBatch           = errors.New("batch cannot be empty")
)

Functions

func IsErrTooOld added in v1.1.0

func IsErrTooOld(err error) bool

Types

type EarnRequest

type EarnRequest struct {
	UserAddr   string `json:"userAddr"`
	Source     string `json:"source"`
	SubSource  string `json:"subSource"`
	SourceUser string `json:"sourceUser"`
	StartBlock int64  `json:"startBlock"`
	StartTime  int64  `json:"startTime"`
	EarnRate   string `json:"earnRate"`
}

func (EarnRequest) Clone

func (er EarnRequest) Clone() EarnRequest

func (EarnRequest) GetSourceUser

func (e EarnRequest) GetSourceUser() string

func (EarnRequest) IsPerBlock

func (e EarnRequest) IsPerBlock() bool

func (EarnRequest) ReferralBonuses

func (e EarnRequest) ReferralBonuses(referralChain []string, tierEarnRates map[int]*big.Rat) ([]EarnRequest, error)

func (EarnRequest) Validate

func (e EarnRequest) Validate() error

type EarnRequestBatch

type EarnRequestBatch struct {
	UserAddrs   []string `json:"userAddrs"`
	Source      string   `json:"source"`
	SubSource   string   `json:"subSource"`
	SourceUsers []string `json:"sourceUsers"`
	StartBlock  int64    `json:"startBlock"`
	StartTime   int64    `json:"startTime"`
	EarnRates   []string `json:"earnRates"`
}

EarnRequestBatch is a batch of related earn requests

func BatchEarnRequests

func BatchEarnRequests(earnRequests []EarnRequest) (EarnRequestBatch, error)

func MakeManyEarnRequestBatches

func MakeManyEarnRequestBatches(earnRequests []EarnRequest, batchSize int) ([]EarnRequestBatch, error)

func (EarnRequestBatch) Clone

func (EarnRequestBatch) IsPerBlock

func (e EarnRequestBatch) IsPerBlock() bool

func (EarnRequestBatch) Size

func (e EarnRequestBatch) Size() int

func (EarnRequestBatch) Validate

func (e EarnRequestBatch) Validate() error

func (EarnRequestBatch) WithReferralBonuses

func (e EarnRequestBatch) WithReferralBonuses(referralChains [][]string, tierEarnRates map[int]*big.Rat) (EarnRequestBatch, error)

type EarnRequestFullBatch

type EarnRequestFullBatch struct {
	UserAddrs   []string `json:"userAddrs"`
	Sources     []string `json:"sources"`
	SubSources  []string `json:"subSources"`
	SourceUsers []string `json:"sourceUsers"`
	StartBlocks []int64  `json:"startBlocks"`
	StartTimes  []int64  `json:"startTimes"`
	EarnRates   []string `json:"earnRates"`
}

EarnRequestFullBatch is a batch of unrelated earn requests

func BatchUnrelatedEarnRequests

func BatchUnrelatedEarnRequests(earnRequests []EarnRequest) (EarnRequestFullBatch, error)

func MakeManyEarnRequestFullBatches

func MakeManyEarnRequestFullBatches(earnRequests []EarnRequest, batchSize int) ([]EarnRequestFullBatch, error)

func (EarnRequestFullBatch) Clone

func (EarnRequestFullBatch) IsPerBlock

func (e EarnRequestFullBatch) IsPerBlock() bool

func (EarnRequestFullBatch) Size

func (e EarnRequestFullBatch) Size() int

func (EarnRequestFullBatch) Validate

func (e EarnRequestFullBatch) Validate() error

func (EarnRequestFullBatch) WithReferralBonuses

func (e EarnRequestFullBatch) WithReferralBonuses(referralChains [][]string, tierEarnRates map[int]*big.Rat) (EarnRequestFullBatch, error)

type GrantRequest added in v1.4.0

type GrantRequest struct {
	UUID            uuid.UUID `json:"uuid"`
	UserAddr        string    `json:"userAddr"`
	Amount          string    `json:"amount"`
	Source          string    `json:"source"`
	SubSource       string    `json:"subSource"`
	SourceUser      string    `json:"-"`
	Category        string    `json:"category"`
	GrantTime       int64     `json:"grantTime"`
	ExcludeReferral bool      `json:"excludeReferral"`
}

func (GrantRequest) GetSourceUser added in v1.4.0

func (gr GrantRequest) GetSourceUser() string

func (GrantRequest) ReferralBonuses added in v1.4.0

func (gr GrantRequest) ReferralBonuses(referralChain []string, tierEarnRates map[int]*big.Rat) []GrantRequest

func (GrantRequest) Validate added in v1.4.0

func (g GrantRequest) Validate() error

type KernelError added in v1.5.0

type KernelError struct {
	Err string `json:"error"`
}

func (KernelError) Error added in v1.5.0

func (ke KernelError) Error() string

type PointsEarnRequest

type PointsEarnRequest struct {
	EarnRequest
	Program int64 `json:"program"`
}

func (PointsEarnRequest) IsPerBlock

func (b PointsEarnRequest) IsPerBlock() bool

func (PointsEarnRequest) Validate

func (b PointsEarnRequest) Validate() error

type PointsEarnRequestBatch

type PointsEarnRequestBatch struct {
	EarnRequestBatch
	Program int64 `json:"program"`
}

func (PointsEarnRequestBatch) IsPerBlock

func (b PointsEarnRequestBatch) IsPerBlock() bool

func (PointsEarnRequestBatch) Validate

func (b PointsEarnRequestBatch) Validate() error

type PointsEarnRequestFullBatch

type PointsEarnRequestFullBatch struct {
	EarnRequestFullBatch
	Program int64 `json:"program"`
}

func (PointsEarnRequestFullBatch) IsPerBlock

func (b PointsEarnRequestFullBatch) IsPerBlock() bool

func (PointsEarnRequestFullBatch) Validate

func (b PointsEarnRequestFullBatch) Validate() error

Jump to

Keyboard shortcuts

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