keeper

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EPOCH_BLOCK_DIVIDER uint64 = 5 // determines how many blocks from the previous epoch will be included in the average block time calculation
	MIN_SAMPLE_STEP     uint64 = 1 // the minimal sample step when calculating the average block time
)

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

Types

type BadgeData

type BadgeData struct {
	Badge       types.Badge
	BadgeSigner sdk.AccAddress
}

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	ps paramtypes.Subspace,

	bankKeeper types.BankKeeper,
	accountKeeper types.AccountKeeper,
	specKeeper types.SpecKeeper,
	epochStorageKeeper types.EpochstorageKeeper,
	projectsKeeper types.ProjectsKeeper,
	subscriptionKeeper types.SubscriptionKeeper,
	planKeeper types.PlanKeeper,
	downtimeKeeper types.DowntimeKeeper,
) *Keeper

func (Keeper) AddEpochPayment added in v0.4.3

func (k Keeper) AddEpochPayment(ctx sdk.Context, chainID string, epoch uint64, projectID string, providerAddress sdk.AccAddress, usedCU uint64, uniqueIdentifier string) (uint64, error)

Function to add an epoch payment to the epochPayments object

func (Keeper) AddProviderPaymentInEpoch added in v0.4.3

func (k Keeper) AddProviderPaymentInEpoch(ctx sdk.Context, chainID string, epoch uint64, projectID string, providerAddress sdk.AccAddress, usedCU uint64, uniqueIdentifier string) (userPayment *types.ProviderPaymentStorage, usedCUConsumerTotal uint64, err error)

Function to add a payment (which is represented by a uniquePaymentStorageClientProvider object) to a providerPaymentStorage object

func (Keeper) AddUniquePaymentStorageClientProvider added in v0.4.3

func (k Keeper) AddUniquePaymentStorageClientProvider(ctx sdk.Context, chainID string, block uint64, projectID string, providerAddress sdk.AccAddress, uniqueIdentifier string, usedCU uint64) (isUnique bool, entryAddr *types.UniquePaymentStorageClientProvider)

func (Keeper) BadgeUsedCuExpiry

func (k Keeper) BadgeUsedCuExpiry(ctx sdk.Context, badge types.Badge) uint64

func (Keeper) BailEntry

func (k Keeper) BailEntry(ctx sdk.Context, account sdk.AccAddress, chainID string, bail sdk.Coin) error

func (Keeper) BeginBlock

func (k Keeper) BeginBlock(ctx sdk.Context)

func (Keeper) CalculateEffectiveAllowedCuPerEpochFromPolicies

func (k Keeper) CalculateEffectiveAllowedCuPerEpochFromPolicies(policies []*planstypes.Policy, cuUsedInProject, cuLeftInSubscription uint64) (allowedCUThisEpoch, allowedCUTotal uint64)

func (Keeper) CalculateEffectiveGeolocationFromPolicies

func (k Keeper) CalculateEffectiveGeolocationFromPolicies(policies []*planstypes.Policy) (int32, error)

func (Keeper) CalculateEffectiveProvidersToPairFromPolicies

func (k Keeper) CalculateEffectiveProvidersToPairFromPolicies(policies []*planstypes.Policy) (uint64, error)

func (Keeper) CalculateEffectiveSelectedProviders

func (k Keeper) CalculateEffectiveSelectedProviders(policies []*planstypes.Policy) (planstypes.SELECTED_PROVIDERS_MODE, []string)

func (Keeper) CheckUnstakingForCommit

func (k Keeper) CheckUnstakingForCommit(ctx sdk.Context)

func (Keeper) CreditStakeEntry

func (k Keeper) CreditStakeEntry(ctx sdk.Context, chainID string, lookUpAddress sdk.AccAddress, creditAmount sdk.Coin) (bool, error)

func (Keeper) DataReliabilityReward added in v0.4.3

func (k Keeper) DataReliabilityReward(ctx sdk.Context) (res sdk.Dec)

func (Keeper) EncodeUniquePaymentKey

func (k Keeper) EncodeUniquePaymentKey(ctx sdk.Context, projectID string, providerAddress sdk.AccAddress, uniqueIdentifier, chainID string) string

func (Keeper) EnforceClientCUsUsageInEpoch

func (k Keeper) EnforceClientCUsUsageInEpoch(ctx sdk.Context, allowedCU, totalCUInEpochForUserProvider uint64, clientAddr sdk.AccAddress, chainID string, epoch uint64) error

func (Keeper) EpochBlocksOverlap

func (k Keeper) EpochBlocksOverlap(ctx sdk.Context) (res uint64)

func (Keeper) ExportBadgesTimers

func (k Keeper) ExportBadgesTimers(ctx sdk.Context) []commontypes.RawMessage

ExportBadgesTimers exports badges timers data (for genesis)

func (Keeper) ExportProviderQoS

func (k Keeper) ExportProviderQoS(ctx sdk.Context) commontypes.GenesisState

func (Keeper) FraudSlashingAmount added in v0.4.3

func (k Keeper) FraudSlashingAmount(ctx sdk.Context) (res uint64)

FraudSlashingAmount returns the FraudSlashingAmount param

func (Keeper) FraudStakeSlashingFactor added in v0.4.3

func (k Keeper) FraudStakeSlashingFactor(ctx sdk.Context) (res sdk.Dec)

FraudStakeSlashingFactor returns the FraudStakeSlashingFactor param

func (Keeper) FreezeProvider

func (k Keeper) FreezeProvider(ctx sdk.Context, provider string, chainIDs []string, reason string) error

func (Keeper) GetAllBadgeUsedCu

func (k Keeper) GetAllBadgeUsedCu(ctx sdk.Context) (list []types.BadgeUsedCu)

GetAllBadgeUsedCu returns all badgeUsedCu

func (Keeper) GetAllChainIDs

func (k Keeper) GetAllChainIDs(ctx sdk.Context) []string

func (Keeper) GetAllEpochPayments

func (k Keeper) GetAllEpochPayments(ctx sdk.Context) (list []types.EpochPayments)

GetAllEpochPayments returns all epochPayments

func (Keeper) GetAllProviderPaymentStorage

func (k Keeper) GetAllProviderPaymentStorage(ctx sdk.Context) (list []types.ProviderPaymentStorage)

GetAllProviderPaymentStorage returns all providerPaymentStorage

func (Keeper) GetAllUniquePaymentStorageClientProvider

func (k Keeper) GetAllUniquePaymentStorageClientProvider(ctx sdk.Context) (list []types.UniquePaymentStorageClientProvider)

GetAllUniquePaymentStorageClientProvider returns all uniquePaymentStorageClientProvider

func (Keeper) GetBadgeUsedCu

func (k Keeper) GetBadgeUsedCu(
	ctx sdk.Context,
	badgeUsedCuKey []byte,
) (val types.BadgeUsedCu, found bool)

GetBadgeUsedCu returns a badgeUsedCu from its index

func (Keeper) GetConsumerFromUniquePayment

func (k Keeper) GetConsumerFromUniquePayment(uniquePaymentStorageClientProvider *types.UniquePaymentStorageClientProvider) string

func (Keeper) GetEpochPayments

func (k Keeper) GetEpochPayments(
	ctx sdk.Context,
	index string,
) (val types.EpochPayments, found bool)

GetEpochPayments returns a epochPayments from its index

func (Keeper) GetEpochPaymentsFromBlock

func (k Keeper) GetEpochPaymentsFromBlock(ctx sdk.Context, epoch uint64) (epochPayment types.EpochPayments, found bool, key string)

Function to get the epochPayments object from a specific epoch. Note that it also returns the epochPayments object's key which is the epoch in hex representation (base 16)

func (Keeper) GetPairing

Gets a client's provider list in a specific chain. Also returns the start block of the current epoch, time (in seconds) until there's a new pairing, the block that the chain in the request's spec was changed

func (Keeper) GetPairingForClient

func (k Keeper) GetPairingForClient(ctx sdk.Context, chainID string, clientAddress sdk.AccAddress) (providers []epochstoragetypes.StakeEntry, errorRet error)

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) types.Params

GetParams get all parameters as types.Params

func (Keeper) GetProjectData

func (k Keeper) GetProjectData(ctx sdk.Context, developerKey sdk.AccAddress, chainID string, blockHeight uint64) (proj projectstypes.Project, errRet error)

func (Keeper) GetProjectStrictestPolicy

func (k Keeper) GetProjectStrictestPolicy(ctx sdk.Context, project projectstypes.Project, chainID string) (*planstypes.Policy, string, error)

func (Keeper) GetProviderPaymentStorage

func (k Keeper) GetProviderPaymentStorage(
	ctx sdk.Context,
	index string,
) (val types.ProviderPaymentStorage, found bool)

GetProviderPaymentStorage returns a providerPaymentStorage from its index

func (Keeper) GetProviderPaymentStorageKey

func (k Keeper) GetProviderPaymentStorageKey(ctx sdk.Context, chainID string, epoch uint64, providerAddress sdk.AccAddress) string

Function to get a providerPaymentStorage object's key (key is chainID_epoch_providerAddress, epoch in hex representation)

func (Keeper) GetQos

func (k Keeper) GetQos(ctx sdk.Context, chainID string, cluster string, provider string) (pairingtypes.QualityOfServiceReport, error)

GetQos gets a provider's QoS excellence report from the providerQosFS

func (Keeper) GetStakeEntry

func (k Keeper) GetStakeEntry(ctx sdk.Context, chainID string, provider string) (epochstoragetypes.StakeEntry, error)

func (Keeper) GetTotalUsedCUForConsumerPerEpoch added in v0.4.3

func (k Keeper) GetTotalUsedCUForConsumerPerEpoch(ctx sdk.Context, projectID string, uniquePaymentStorageKeys []string, providerAddress string) (uint64, error)

Function to get the total serviced CU by a provider in this epoch for a specific consumer

func (Keeper) GetUniquePaymentStorageClientProvider

func (k Keeper) GetUniquePaymentStorageClientProvider(
	ctx sdk.Context,
	index string,
) (val types.UniquePaymentStorageClientProvider, found bool)

GetUniquePaymentStorageClientProvider returns a uniquePaymentStorageClientProvider from its index

func (Keeper) InitBadgeTimers

func (k Keeper) InitBadgeTimers(ctx sdk.Context, data []commontypes.RawMessage)

InitBadgeTimers imports badges timers data (from genesis)

func (Keeper) InitProviderQoS

func (k Keeper) InitProviderQoS(ctx sdk.Context, gs commontypes.GenesisState)

func (Keeper) JailEntry

func (k Keeper) JailEntry(ctx sdk.Context, account sdk.AccAddress, chainID string, jailStartBlock, jailBlocks uint64, bail sdk.Coin) error

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) MintCoinsPerCU added in v0.4.3

func (k Keeper) MintCoinsPerCU(ctx sdk.Context) (res sdk.Dec)

MintCoinsPerCU returns the MintCoinsPerCU param

func (Keeper) Params

func (Keeper) Providers

func (Keeper) QoSWeight

func (k Keeper) QoSWeight(ctx sdk.Context) (res sdk.Dec)

func (Keeper) RecommendedEpochNumToCollectPayment

func (k Keeper) RecommendedEpochNumToCollectPayment(ctx sdk.Context) (res uint64)

RecommendedEpochNumToCollectPayment returns the RecommendedEpochNumToCollectPayment param

func (Keeper) RemoveAllEpochPaymentsForBlock added in v0.4.3

func (k Keeper) RemoveAllEpochPaymentsForBlock(ctx sdk.Context, blockForDelete uint64)

Function to remove all epochPayments objects from a specific epoch

func (Keeper) RemoveBadgeUsedCu

func (k Keeper) RemoveBadgeUsedCu(
	ctx sdk.Context,
	badgeUsedCuKey []byte,
)

RemoveBadgeUsedCu removes a badgeUsedCu from the store

func (Keeper) RemoveEpochPayments

func (k Keeper) RemoveEpochPayments(
	ctx sdk.Context,
	index string,
)

RemoveEpochPayments removes a epochPayments from the store

func (Keeper) RemoveOldEpochPayment

func (k Keeper) RemoveOldEpochPayment(ctx sdk.Context)

Function to remove epochPayments objects from deleted epochs (older than the chain's memory)

func (Keeper) RemoveProviderPaymentStorage

func (k Keeper) RemoveProviderPaymentStorage(
	ctx sdk.Context,
	index string,
)

RemoveProviderPaymentStorage removes a providerPaymentStorage from the store

func (Keeper) RemoveUniquePaymentStorageClientProvider

func (k Keeper) RemoveUniquePaymentStorageClientProvider(
	ctx sdk.Context,
	index string,
)

RemoveUniquePaymentStorageClientProvider removes a uniquePaymentStorageClientProvider from the store

func (Keeper) SdkPairing

func (Keeper) SetBadgeUsedCu

func (k Keeper) SetBadgeUsedCu(ctx sdk.Context, badgeUsedCu types.BadgeUsedCu)

SetBadgeUsedCu set a specific badgeUsedCu in the store from its index

func (Keeper) SetEpochPayments

func (k Keeper) SetEpochPayments(ctx sdk.Context, epochPayments types.EpochPayments)

SetEpochPayments set a specific epochPayments in the store from its index

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams set the params

func (Keeper) SetProviderPaymentStorage

func (k Keeper) SetProviderPaymentStorage(ctx sdk.Context, providerPaymentStorage types.ProviderPaymentStorage)

SetProviderPaymentStorage set a specific providerPaymentStorage in the store from its index

func (Keeper) SetRecommendedEpochNumToCollectPayment

func (k Keeper) SetRecommendedEpochNumToCollectPayment(ctx sdk.Context, val uint64)

func (Keeper) SetUniquePaymentStorageClientProvider

func (k Keeper) SetUniquePaymentStorageClientProvider(ctx sdk.Context, uniquePaymentStorageClientProvider types.UniquePaymentStorageClientProvider)

SetUniquePaymentStorageClientProvider set a specific uniquePaymentStorageClientProvider in the store from its index

func (Keeper) SlashEntry

func (k Keeper) SlashEntry(ctx sdk.Context, account sdk.AccAddress, chainID string, percentage sdk.Dec) (sdk.Coin, error)

func (Keeper) SlashLimit added in v0.4.3

func (k Keeper) SlashLimit(ctx sdk.Context) (res sdk.Dec)

func (Keeper) StakeNewEntry

func (k Keeper) StakeNewEntry(ctx sdk.Context, creator, chainID string, amount sdk.Coin, endpoints []epochstoragetypes.Endpoint, geolocation int32, moniker string) error

func (Keeper) UnpayLimit added in v0.4.3

func (k Keeper) UnpayLimit(ctx sdk.Context) (res sdk.Dec)

func (Keeper) UnstakeEntry

func (k Keeper) UnstakeEntry(ctx sdk.Context, chainID, creator, unstakeDescription string) error

func (Keeper) UnstakeUnresponsiveProviders

func (k Keeper) UnstakeUnresponsiveProviders(ctx sdk.Context, epochsNumToCheckCUForUnresponsiveProvider, epochsNumToCheckCUForComplainers uint64)

Function that returns a map that links between a provider that should be punished and its providerCuCounterForUnreponsiveness

func (Keeper) UpdateProviderQos

func (k Keeper) UpdateProviderQos(epochPayments pairingtypes.EpochPayments)

func (Keeper) UserEntry

func (Keeper) ValidatePairingForClient

func (k Keeper) ValidatePairingForClient(ctx sdk.Context, chainID string, clientAddress, providerAddress sdk.AccAddress, epoch uint64) (isValidPairing bool, allowedCU, pairedProviders uint64, projectID string, errorRet error)

func (Keeper) VerifyClientStake added in v0.8.1

func (k Keeper) VerifyClientStake(ctx sdk.Context, chainID string, clientAddress sdk.Address, block, epoch uint64) (clientStakeEntryRet *epochstoragetypes.StakeEntry, errorRet error)

func (Keeper) VerifyPairingData

func (k Keeper) VerifyPairingData(ctx sdk.Context, chainID string, clientAddress sdk.AccAddress, block uint64) (epoch uint64, providersType spectypes.Spec_ProvidersTypes, errorRet error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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