rewardserver

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RewardServerStorageFlagName         = "reward-server-storage"
	DefaultRewardServerStorage          = ".storage/rewardserver"
	RewardTTLFlagName                   = "reward-ttl"
	DefaultRewardTTL                    = 24 * 60 * time.Minute
	MaxDBSaveRetries                    = 10
	RewardsSnapshotThresholdFlagName    = "proofs-snapshot-threshold"
	DefaultRewardsSnapshotThreshold     = 1000
	RewardsSnapshotTimeoutSecFlagName   = "proofs-snapshot-timeout-sec"
	DefaultRewardsSnapshotTimeoutSec    = 30
	MaxPaymentRequestsRetiresForSession = 3
	RewardServerMaxRelayRetires         = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerDB

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

func (*BadgerDB) BatchSave

func (mdb *BadgerDB) BatchSave(dbEntries []*DBEntry) error

func (*BadgerDB) Close

func (mdb *BadgerDB) Close() error

func (*BadgerDB) Delete

func (mdb *BadgerDB) Delete(key string) error

func (*BadgerDB) DeletePrefix

func (mdb *BadgerDB) DeletePrefix(prefix string) error

func (*BadgerDB) FindAll

func (mdb *BadgerDB) FindAll() (map[string][]byte, error)

func (*BadgerDB) FindOne

func (mdb *BadgerDB) FindOne(key string) (one []byte, err error)

func (*BadgerDB) Key

func (mdb *BadgerDB) Key() string

func (*BadgerDB) Save

func (mdb *BadgerDB) Save(dbEntry *DBEntry) error

type ChainTrackerSpecsInf

type ChainTrackerSpecsInf interface {
	GetLatestBlockNumForSpec(specID string) int64
}

type ConsumerRewards

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

func (*ConsumerRewards) PrepareRewardsForClaim

func (csrw *ConsumerRewards) PrepareRewardsForClaim() (retProofs []*pairingtypes.RelaySession, errRet error)

type DB

type DB interface {
	Key() string
	Save(dbEntry *DBEntry) error
	BatchSave(dbEntries []*DBEntry) error
	FindOne(key string) ([]byte, error)
	FindAll() (map[string][]byte, error)
	Delete(key string) error
	DeletePrefix(prefix string) error
	Close() error
}

func NewLocalDB

func NewLocalDB(storagePath, providerAddr string, specId string, shard uint) DB

func NewMemoryDB

func NewMemoryDB(specId string) DB

type DBEntry

type DBEntry struct {
	Key  string
	Data []byte
	Ttl  time.Duration
}

type EpochRewards

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

type PaymentConfiguration added in v1.0.4

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

type PaymentRequest

type PaymentRequest struct {
	CU                  uint64
	BlockHeightDeadline int64
	PaymentEpoch        uint64
	Amount              sdk.Coin
	Client              sdk.AccAddress
	UniqueIdentifier    uint64
	Description         string
	ChainID             string
	ConsumerRewardsKey  string
}

func BuildPaymentFromRelayPaymentEvent

func BuildPaymentFromRelayPaymentEvent(event terderminttypes.Event, block int64) ([]*PaymentRequest, error)

func (*PaymentRequest) String

func (pr *PaymentRequest) String() string

type RelaySessionsToRetryAttempts

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

type RewardDB

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

func NewRewardDB

func NewRewardDB() *RewardDB

func NewRewardDBWithTTL

func NewRewardDBWithTTL(ttl time.Duration) *RewardDB

func (*RewardDB) AddDB

func (rs *RewardDB) AddDB(db DB) error

func (*RewardDB) BatchSave

func (rs *RewardDB) BatchSave(rewardEntities []*RewardEntity) (err error)

func (*RewardDB) Close

func (rs *RewardDB) Close() error

func (*RewardDB) DBExists

func (rs *RewardDB) DBExists(specId string) bool

func (*RewardDB) DeleteClaimedRewards

func (rs *RewardDB) DeleteClaimedRewards(epoch uint64, consumerAddr string, sessionId uint64, consumerRewardsKey string) (err error)

func (*RewardDB) DeleteEpochRewards

func (rs *RewardDB) DeleteEpochRewards(epoch uint64) error

func (*RewardDB) FindAll

func (rs *RewardDB) FindAll() (map[uint64]*EpochRewards, error)

func (*RewardDB) FindAllInDB

func (rs *RewardDB) FindAllInDB(specId string) (map[uint64]*EpochRewards, error)

TODO: Add tests for this func

func (*RewardDB) FindOne

func (rs *RewardDB) FindOne(
	epoch uint64,
	consumerAddr string,
	consumerKey string,
	sessionId uint64,
) (*pairingtypes.RelaySession, error)

currently unused

func (*RewardDB) Save

func (rs *RewardDB) Save(rewardEntity *RewardEntity) error

type RewardEntity

type RewardEntity struct {
	Epoch        uint64
	ConsumerAddr string
	ConsumerKey  string
	SessionId    uint64
	Proof        *pairingtypes.RelaySession
}

type RewardServer

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

func NewRewardServer

func NewRewardServer(rewardsTxSender RewardsTxSender, providerMetrics *metrics.ProviderMetricsManager, rewardDB *RewardDB, rewardStoragePath string, rewardsSnapshotThreshold uint, rewardsSnapshotTimeoutSec uint, chainTrackerSpecsInf ChainTrackerSpecsInf) *RewardServer

func (*RewardServer) AddDataBase

func (rws *RewardServer) AddDataBase(specId string, providerPublicAddress string, shardID uint)

func (*RewardServer) AddRewardDelayForUnifiedRewardDistribution

func (rws *RewardServer) AddRewardDelayForUnifiedRewardDistribution(ctx context.Context, epochStart uint64)

func (*RewardServer) CloseAllDataBases

func (rws *RewardServer) CloseAllDataBases() error

func (*RewardServer) Description

func (rws *RewardServer) Description() string

func (*RewardServer) PaymentHandler

func (rws *RewardServer) PaymentHandler(payment *PaymentRequest)

func (*RewardServer) RemoveExpectedPayment

func (rws *RewardServer) RemoveExpectedPayment(paidCUToFInd uint64, expectedClient sdk.AccAddress, blockHeight int64, uniqueID uint64, chainID string) bool

func (*RewardServer) SendNewProof

func (rws *RewardServer) SendNewProof(ctx context.Context, proof *pairingtypes.RelaySession, epoch uint64, consumerAddr string, apiInterface string) (existingCU uint64, updatedWithProof bool)

func (*RewardServer) SubscribeEnded

func (rws *RewardServer) SubscribeEnded(consumer string, epoch uint64, subscribeID string)

func (*RewardServer) SubscribeStarted

func (rws *RewardServer) SubscribeStarted(consumer string, epoch uint64, subscribeID string)

func (*RewardServer) UpdateEpoch

func (rws *RewardServer) UpdateEpoch(epoch uint64)

type RewardsTxSender

type RewardsTxSender interface {
	TxRelayPayment(ctx context.Context, relayRequests []*pairingtypes.RelaySession, description string, latestBlocks []*pairingtypes.LatestBlockReport) error
	GetEpochSizeMultipliedByRecommendedEpochNumToCollectPayment(ctx context.Context) (uint64, error)
	EarliestBlockInMemory(ctx context.Context) (uint64, error)
	GetEpochSize(ctx context.Context) (uint64, error)
	LatestBlock() int64
	GetAverageBlockTime() time.Duration
}

Jump to

Keyboard shortcuts

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