keeper

package
v0.0.0-...-a41a74f Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper, sk stakingkeeper.Keeper) types.MsgServer

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

Types

type KVStore

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

func NewKVStore

func NewKVStore(
	cdc codec.BinaryCodec,
	storeKey,
	memKey storetypes.StoreKey,
	ps paramtypes.Subspace,
	coinKeeper bankkeeper.Keeper,
	accountKeeper authkeeper.AccountKeeper,
	stakingKeeper stakingkeeper.Keeper,
) *KVStore

func (KVStore) AddCoins

func (k KVStore) AddCoins(ctx cosmos.Context, addr cosmos.AccAddress, coins cosmos.Coins) error

func (KVStore) BurnFromModule

func (k KVStore) BurnFromModule(ctx cosmos.Context, module string, coin cosmos.Coin) error

func (KVStore) Cdc

func (k KVStore) Cdc() codec.BinaryCodec

Cdc return the amino codec

func (KVStore) ContractExists

func (k KVStore) ContractExists(ctx cosmos.Context, id uint64) bool

ContractExists check whether the given contract exist in the data store

func (KVStore) GetAccount

func (k KVStore) GetAccount(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Account

func (KVStore) GetActiveContractForUser

func (k KVStore) GetActiveContractForUser(ctx cosmos.Context, user, provider common.PubKey, service common.Service) (types.Contract, error)

func (KVStore) GetActiveValidators

func (k KVStore) GetActiveValidators(ctx cosmos.Context) []stakingtypes.Validator

func (KVStore) GetAndIncrementNextContractId

func (kvStore KVStore) GetAndIncrementNextContractId(ctx cosmos.Context) uint64

func (KVStore) GetBalance

func (k KVStore) GetBalance(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Coins

func (KVStore) GetBalanceOfModule

func (k KVStore) GetBalanceOfModule(ctx cosmos.Context, moduleName, denom string) cosmos.Int

func (KVStore) GetComputedVersion

func (k KVStore) GetComputedVersion(ctx cosmos.Context) int64

func (KVStore) GetContract

func (k KVStore) GetContract(ctx cosmos.Context, id uint64) (types.Contract, error)

GetContract get the entire Contract metadata struct based on given asset

func (KVStore) GetContractExpirationSet

func (k KVStore) GetContractExpirationSet(ctx cosmos.Context, height int64) (types.ContractExpirationSet, error)

GetContractExpirationSet get a series of contract expirations

func (KVStore) GetContractExpirationSetIterator

func (k KVStore) GetContractExpirationSetIterator(ctx cosmos.Context) cosmos.Iterator

GetContractExpirationSetIterator iterate contract expiration sets

func (KVStore) GetContractIterator

func (k KVStore) GetContractIterator(ctx cosmos.Context) cosmos.Iterator

GetContractIterator iterate contract

func (KVStore) GetContractKey

func (k KVStore) GetContractKey(ctx cosmos.Context, id uint64) string

func (KVStore) GetKey

func (k KVStore) GetKey(ctx cosmos.Context, prefix dbPrefix, key string) string

GetKey return a key that can be used to store into key value store

func (KVStore) GetModuleAccAddress

func (k KVStore) GetModuleAccAddress(module string) cosmos.AccAddress

func (KVStore) GetModuleAddress

func (k KVStore) GetModuleAddress(module string) (cosmos.AccAddress, error)

func (KVStore) GetNextContractId

func (kvStore KVStore) GetNextContractId(ctx cosmos.Context) uint64

func (KVStore) GetParams

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

GetParams get all parameters as types.Params

func (KVStore) GetProvider

func (k KVStore) GetProvider(ctx cosmos.Context, pubkey common.PubKey, service common.Service) (types.Provider, error)

GetProvider get the entire Provider metadata struct based on given asset

func (KVStore) GetProviderIterator

func (k KVStore) GetProviderIterator(ctx cosmos.Context) cosmos.Iterator

GetProviderIterator iterate providers

func (KVStore) GetSupply

func (k KVStore) GetSupply(ctx cosmos.Context, denom string) cosmos.Coin

func (KVStore) GetUserContractSet

func (k KVStore) GetUserContractSet(ctx cosmos.Context, user common.PubKey) (types.UserContractSet, error)

func (KVStore) GetUserContractSetIterator

func (k KVStore) GetUserContractSetIterator(ctx cosmos.Context) cosmos.Iterator

func (KVStore) GetVersion

func (k KVStore) GetVersion(ctx cosmos.Context) int64

GetVersion get the current key value store version

func (KVStore) GetVersionForAddress

func (k KVStore) GetVersionForAddress(ctx cosmos.Context, addr cosmos.ValAddress) int64

GetVersionForAddress get the current key value store version

func (KVStore) HasCoins

func (k KVStore) HasCoins(ctx cosmos.Context, addr cosmos.AccAddress, coins cosmos.Coins) bool

func (KVStore) Logger

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

func (KVStore) MintAndSendToAccount

func (k KVStore) MintAndSendToAccount(ctx cosmos.Context, to cosmos.AccAddress, coin cosmos.Coin) error

func (KVStore) MintToModule

func (k KVStore) MintToModule(ctx cosmos.Context, module string, coin cosmos.Coin) error

func (KVStore) Params

func (KVStore) ProviderExists

func (k KVStore) ProviderExists(ctx cosmos.Context, pubkey common.PubKey, service common.Service) bool

ProviderExists check whether the given provider exist in the data store

func (KVStore) RemoveContract

func (k KVStore) RemoveContract(ctx cosmos.Context, id uint64)

func (KVStore) RemoveContractExpirationSet

func (k KVStore) RemoveContractExpirationSet(ctx cosmos.Context, height int64)

func (KVStore) RemoveFromUserContractSet

func (k KVStore) RemoveFromUserContractSet(ctx cosmos.Context, user common.PubKey, contractId uint64) error

RemoveFromUserContractSet remove a contract from a user's contract set and saves the updated set to the store

func (KVStore) RemoveProvider

func (k KVStore) RemoveProvider(ctx cosmos.Context, pubkey common.PubKey, service common.Service)

func (KVStore) SendCoins

func (k KVStore) SendCoins(ctx cosmos.Context, from, to cosmos.AccAddress, coins cosmos.Coins) error

func (KVStore) SendFromAccountToModule

func (k KVStore) SendFromAccountToModule(ctx cosmos.Context, from cosmos.AccAddress, to string, coins cosmos.Coins) error

SendFromAccountToModule transfer fund from one account to a module

func (KVStore) SendFromModuleToAccount

func (k KVStore) SendFromModuleToAccount(ctx cosmos.Context, from string, to cosmos.AccAddress, coins cosmos.Coins) error

SendFromModuleToAccount transfer fund from module to an account

func (KVStore) SendFromModuleToModule

func (k KVStore) SendFromModuleToModule(ctx cosmos.Context, from, to string, coins cosmos.Coins) error

SendFromModuleToModule transfer asset from one module to another

func (KVStore) SetContract

func (k KVStore) SetContract(ctx cosmos.Context, contract types.Contract) error

SetContract save the entire Contract metadata struct to key value store

func (KVStore) SetContractExpirationSet

func (k KVStore) SetContractExpirationSet(ctx cosmos.Context, record types.ContractExpirationSet) error

SetContractExpirationSet save the series of Contract Expirations

func (KVStore) SetNextContractId

func (k KVStore) SetNextContractId(ctx cosmos.Context, contractId uint64)

func (KVStore) SetParams

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

SetParams set the params

func (KVStore) SetProvider

func (k KVStore) SetProvider(ctx cosmos.Context, provider types.Provider) error

SetProvider save the entire Provider metadata struct to key value store

func (KVStore) SetUserContractSet

func (k KVStore) SetUserContractSet(ctx cosmos.Context, contractSet types.UserContractSet) error

func (KVStore) SetVersion

func (k KVStore) SetVersion(ctx cosmos.Context, value int64)

SetVersion save the store version

func (KVStore) SetVersionForAddress

func (k KVStore) SetVersionForAddress(ctx cosmos.Context, addr cosmos.ValAddress, value int64)

SetVersionForAddress save the store version

func (KVStore) StakingSetParams

func (k KVStore) StakingSetParams(ctx cosmos.Context, params stakingtypes.Params)

type KVStoreDummy

type KVStoreDummy struct{}

func (KVStoreDummy) AccountKeeper

func (k KVStoreDummy) AccountKeeper() authkeeper.AccountKeeper

func (KVStoreDummy) AddCoins

func (k KVStoreDummy) AddCoins(ctx cosmos.Context, _ cosmos.AccAddress, coins cosmos.Coins) error

func (KVStoreDummy) BurnFromModule

func (k KVStoreDummy) BurnFromModule(ctx cosmos.Context, module string, coin cosmos.Coin) error

func (KVStoreDummy) Cdc

func (k KVStoreDummy) Cdc() codec.BinaryCodec

func (KVStoreDummy) CoinKeeper

func (k KVStoreDummy) CoinKeeper() bankkeeper.Keeper

func (KVStoreDummy) ContractExists

func (k KVStoreDummy) ContractExists(_ cosmos.Context, _ common.PubKey, _ common.Service, _ common.PubKey) bool

func (KVStoreDummy) GetAccount

func (k KVStoreDummy) GetAccount(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Account

func (KVStoreDummy) GetActiveValidators

func (k KVStoreDummy) GetActiveValidators(ctx cosmos.Context) []stakingtypes.Validator

func (KVStoreDummy) GetBalance

func (k KVStoreDummy) GetBalance(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Coins

func (KVStoreDummy) GetBalanceOfModule

func (k KVStoreDummy) GetBalanceOfModule(ctx cosmos.Context, moduleName, denom string) cosmos.Int

func (KVStoreDummy) GetContract

func (KVStoreDummy) GetContractExpirationSet

func (k KVStoreDummy) GetContractExpirationSet(_ cosmos.Context, _ int64) (types.ContractExpirationSet, error)

func (KVStoreDummy) GetContractExpirationSetIterator

func (k KVStoreDummy) GetContractExpirationSetIterator(_ cosmos.Context) cosmos.Iterator

func (KVStoreDummy) GetContractIterator

func (k KVStoreDummy) GetContractIterator(_ cosmos.Context) cosmos.Iterator

func (KVStoreDummy) GetKey

func (k KVStoreDummy) GetKey(_ cosmos.Context, prefix dbPrefix, key string) string

func (KVStoreDummy) GetModuleAccAddress

func (k KVStoreDummy) GetModuleAccAddress(module string) cosmos.AccAddress

func (KVStoreDummy) GetModuleAddress

func (k KVStoreDummy) GetModuleAddress(module string) cosmos.AccAddress

func (KVStoreDummy) GetParams

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

func (KVStoreDummy) GetProvider

func (KVStoreDummy) GetProviderIterator

func (k KVStoreDummy) GetProviderIterator(_ cosmos.Context) cosmos.Iterator

func (KVStoreDummy) GetRuneBalanceOfModule

func (k KVStoreDummy) GetRuneBalanceOfModule(ctx cosmos.Context, moduleName string) cosmos.Int

func (KVStoreDummy) GetVersion

func (k KVStoreDummy) GetVersion(ctx cosmos.Context) int64

func (KVStoreDummy) HasCoins

func (k KVStoreDummy) HasCoins(ctx cosmos.Context, addr cosmos.AccAddress, coins cosmos.Coins) bool

func (KVStoreDummy) Logger

func (k KVStoreDummy) Logger(ctx cosmos.Context) log.Logger

func (KVStoreDummy) MintAndSendToAccount

func (k KVStoreDummy) MintAndSendToAccount(ctx cosmos.Context, to cosmos.AccAddress, coin cosmos.Coin) error

func (KVStoreDummy) MintToModule

func (k KVStoreDummy) MintToModule(ctx cosmos.Context, module string, coin cosmos.Coin) error

func (KVStoreDummy) Params

func (KVStoreDummy) ProviderExists

func (k KVStoreDummy) ProviderExists(_ cosmos.Context, _ common.PubKey, _ common.Service) bool

func (KVStoreDummy) RemoveContract

func (k KVStoreDummy) RemoveContract(_ cosmos.Context, _ common.PubKey, _ common.Service, _ common.PubKey)

func (KVStoreDummy) RemoveContractExpirationSet

func (k KVStoreDummy) RemoveContractExpirationSet(_ cosmos.Context, _ int64)

func (KVStoreDummy) RemoveProvider

func (k KVStoreDummy) RemoveProvider(_ cosmos.Context, _ common.PubKey, _ common.Service)

func (KVStoreDummy) SendCoins

func (k KVStoreDummy) SendCoins(ctx cosmos.Context, from, to cosmos.AccAddress, coins cosmos.Coins) error

func (KVStoreDummy) SendFromAccountToModule

func (k KVStoreDummy) SendFromAccountToModule(ctx cosmos.Context, from cosmos.AccAddress, to string, coins cosmos.Coins) error

func (KVStoreDummy) SendFromModuleToAccount

func (k KVStoreDummy) SendFromModuleToAccount(ctx cosmos.Context, from string, to cosmos.AccAddress, coins cosmos.Coins) error

func (KVStoreDummy) SendFromModuleToModule

func (k KVStoreDummy) SendFromModuleToModule(ctx cosmos.Context, from, to string, coins cosmos.Coins) error

func (KVStoreDummy) SetContract

func (k KVStoreDummy) SetContract(_ cosmos.Context, _ types.Contract) error

func (KVStoreDummy) SetContractExpirationSet

func (k KVStoreDummy) SetContractExpirationSet(_ cosmos.Context, _ types.ContractExpirationSet) error

func (KVStoreDummy) SetParams

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

func (KVStoreDummy) SetProvider

func (k KVStoreDummy) SetProvider(_ cosmos.Context, _ types.Provider) error

func (KVStoreDummy) SetVersion

func (k KVStoreDummy) SetVersion(ctx cosmos.Context, ver int64)

func (KVStoreDummy) StakingSetParams

func (k KVStoreDummy) StakingSetParams(ctx cosmos.Context, params stakingtypes.Params)

type Keeper

type Keeper interface {
	Logger(ctx sdk.Context) log.Logger
	GetParams(ctx sdk.Context) types.Params
	SetParams(ctx sdk.Context, params types.Params)
	Cdc() codec.BinaryCodec
	GetComputedVersion(ctx cosmos.Context) int64
	GetVersion(ctx cosmos.Context) int64
	SetVersion(ctx cosmos.Context, ver int64)
	GetKey(ctx cosmos.Context, prefix dbPrefix, key string) string
	GetVersionForAddress(ctx cosmos.Context, _ cosmos.ValAddress) int64
	SetVersionForAddress(ctx cosmos.Context, _ cosmos.ValAddress, ver int64)
	GetSupply(ctx cosmos.Context, denom string) cosmos.Coin
	GetBalanceOfModule(ctx cosmos.Context, moduleName, denom string) cosmos.Int
	SendFromModuleToModule(ctx cosmos.Context, from, to string, coin cosmos.Coins) error
	SendFromAccountToModule(ctx cosmos.Context, from cosmos.AccAddress, to string, _ cosmos.Coins) error
	SendFromModuleToAccount(ctx cosmos.Context, from string, to cosmos.AccAddress, _ cosmos.Coins) error
	MintToModule(ctx cosmos.Context, module string, coin cosmos.Coin) error
	BurnFromModule(ctx cosmos.Context, module string, coin cosmos.Coin) error
	MintAndSendToAccount(ctx cosmos.Context, to cosmos.AccAddress, coin cosmos.Coin) error
	GetModuleAccAddress(module string) cosmos.AccAddress
	GetBalance(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Coins
	HasCoins(ctx cosmos.Context, addr cosmos.AccAddress, coins cosmos.Coins) bool

	// passthrough funcs
	SendCoins(ctx cosmos.Context, from, to cosmos.AccAddress, coins cosmos.Coins) error
	AddCoins(ctx cosmos.Context, addr cosmos.AccAddress, coins cosmos.Coins) error
	GetActiveValidators(ctx cosmos.Context) []stakingtypes.Validator
	GetAccount(ctx cosmos.Context, addr cosmos.AccAddress) cosmos.Account
	StakingSetParams(ctx cosmos.Context, params stakingtypes.Params)

	// Query
	Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
	FetchProvider(c context.Context, req *types.QueryFetchProviderRequest) (*types.QueryFetchProviderResponse, error)
	ProviderAll(c context.Context, req *types.QueryAllProviderRequest) (*types.QueryAllProviderResponse, error)
	FetchContract(c context.Context, req *types.QueryFetchContractRequest) (*types.QueryFetchContractResponse, error)
	ContractAll(c context.Context, req *types.QueryAllContractRequest) (*types.QueryAllContractResponse, error)
	ActiveContract(goCtx context.Context, req *types.QueryActiveContractRequest) (*types.QueryActiveContractResponse, error)

	// Keeper Interfaces
	KeeperProvider
	KeeperContract
}

type KeeperContract

type KeeperContract interface {
	GetContractIterator(_ cosmos.Context) cosmos.Iterator
	GetContract(_ cosmos.Context, _ uint64) (types.Contract, error)
	SetContract(_ cosmos.Context, _ types.Contract) error
	ContractExists(_ cosmos.Context, _ uint64) bool
	RemoveContract(_ cosmos.Context, _ uint64)
	GetContractExpirationSetIterator(_ cosmos.Context) cosmos.Iterator
	GetUserContractSetIterator(_ cosmos.Context) cosmos.Iterator
	GetContractExpirationSet(_ cosmos.Context, _ int64) (types.ContractExpirationSet, error)
	SetContractExpirationSet(_ cosmos.Context, _ types.ContractExpirationSet) error
	RemoveContractExpirationSet(_ cosmos.Context, _ int64)
	RemoveFromUserContractSet(ctx cosmos.Context, user common.PubKey, contractId uint64) error
	GetNextContractId(_ cosmos.Context) uint64
	SetNextContractId(ctx cosmos.Context, contractId uint64)
	GetAndIncrementNextContractId(ctx cosmos.Context) uint64
	SetUserContractSet(ctx cosmos.Context, contractSet types.UserContractSet) error
	GetUserContractSet(ctx cosmos.Context, pubkey common.PubKey) (types.UserContractSet, error)
	GetActiveContractForUser(ctx cosmos.Context, user, provider common.PubKey, service common.Service) (types.Contract, error)
}

type KeeperProvider

type KeeperProvider interface {
	GetProviderIterator(_ cosmos.Context) cosmos.Iterator
	GetProvider(_ cosmos.Context, _ common.PubKey, _ common.Service) (types.Provider, error)
	SetProvider(_ cosmos.Context, _ types.Provider) error
	ProviderExists(_ cosmos.Context, _ common.PubKey, _ common.Service) bool
	RemoveProvider(_ cosmos.Context, _ common.PubKey, _ common.Service)
}

type Manager

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

func NewManager

func NewManager(k Keeper, sk stakingkeeper.Keeper) Manager

func (*Manager) BeginBlock

func (mgr *Manager) BeginBlock(ctx cosmos.Context, req abci.RequestBeginBlock) error

func (Manager) Configs

func (mgr Manager) Configs(ctx cosmos.Context) configs.ConfigValues

func (Manager) ContractEndBlock

func (mgr Manager) ContractEndBlock(ctx cosmos.Context) error

func (Manager) EmitContractSettlementEvent

func (mgr Manager) EmitContractSettlementEvent(ctx cosmos.Context, debt, valIncome cosmos.Int, contract *types.Contract) error

func (Manager) EmitValidatorPayoutEvent

func (mgr Manager) EmitValidatorPayoutEvent(ctx cosmos.Context, acc cosmos.AccAddress, rwd cosmos.Int) error

func (Manager) EndBlock

func (mgr Manager) EndBlock(ctx cosmos.Context) error

func (Manager) FetchConfig

func (mgr Manager) FetchConfig(ctx cosmos.Context, name configs.ConfigName) int64

func (Manager) SettleContract

func (mgr Manager) SettleContract(ctx cosmos.Context, contract types.Contract, nonce int64, isFinal bool) (types.Contract, error)

any owed debt is paid to data provider

func (Manager) ValidatorPayout

func (mgr Manager) ValidatorPayout(ctx cosmos.Context, votes []abci.VoteInfo) error

This function pays out rewards to validators. TODO: the method of accomplishing this is admittedly quite inefficient. The better approach would be to track live allocation via assigning "units" to validators when they bond and unbond. The math for this is as follows U = total bond units T = tokens bonded t = new tokens being bonded units = U / (T / t) Since the development goal at the moment is to get this chain up and running, we can save this optimization for another day.

Jump to

Keyboard shortcuts

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