Documentation
¶
Index ¶
- Constants
- func GetNumBlocksUndelegationRetention(sharedParams *sharedtypes.Params) int64
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- type Keeper
- func (k Keeper) AllApplications(ctx context.Context, req *types.QueryAllApplicationsRequest) (*types.QueryAllApplicationsResponse, error)
- func (k Keeper) Application(ctx context.Context, req *types.QueryGetApplicationRequest) (*types.QueryGetApplicationResponse, error)
- func (k Keeper) CleanupOrphanedUndelegationIndexes(ctx context.Context) (int, error)
- func (k Keeper) EndBlockerAutoUndelegateFromUnbondingGateways(ctx cosmostypes.Context) error
- func (k Keeper) EndBlockerPruneAppToGatewayPendingUndelegation(ctx sdk.Context) error
- func (k Keeper) EndBlockerTransferApplication(ctx context.Context) error
- func (k Keeper) EndBlockerUnbondApplications(ctx context.Context) error
- func (k Keeper) GetAllApplications(ctx context.Context) (apps []types.Application)
- func (k Keeper) GetAllApplicationsIterator(ctx context.Context) sharedtypes.RecordIterator[types.Application]
- func (k Keeper) GetAllTransferringApplicationsIterator(ctx context.Context) sharedtypes.RecordIterator[types.Application]
- func (k Keeper) GetAllUnstakingApplicationsIterator(ctx context.Context) sharedtypes.RecordIterator[types.Application]
- func (k Keeper) GetApplication(ctx context.Context, appAddr string) (app types.Application, found bool)
- func (k Keeper) GetAuthority() string
- func (k Keeper) GetDelegationsIterator(ctx context.Context, gatewayAddress string) sharedtypes.RecordIterator[types.Application]
- func (k Keeper) GetNumBlocksUndelegationRetention(ctx context.Context) int64
- func (k Keeper) GetParams(ctx context.Context) (params types.Params)
- func (k Keeper) GetUndelegationsIterator(ctx context.Context, applicationAddress string) sharedtypes.RecordIterator[types.PendingUndelegation]
- func (k Keeper) Logger() log.Logger
- func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) RemoveApplication(ctx context.Context, application types.Application)
- func (k Keeper) SetApplication(ctx context.Context, application types.Application)
- func (k Keeper) SetParams(ctx context.Context, params types.Params) error
- func (k Keeper) StakeApplication(ctx context.Context, logger cosmoslog.Logger, msg *types.MsgStakeApplication) (_ *types.Application, err error)
- func (k Keeper) UnbondApplication(ctx context.Context, app *apptypes.Application) error
Constants ¶
const ALL_UNDELEGATIONS = ""
const NumSessionsAppToGatewayUndelegationRetention = 2
NumSessionsAppToGatewayUndelegationRetention is the number of sessions for which undelegation from applications to gateways are delayed before being pruned. TODO_DOCUMENT(@red-0ne): Need to document the flow from this comment so its clear to everyone why this is necessary; https://github.com/pokt-network/poktroll/issues/476#issuecomment-2052639906. TODO_MAINNET(#516): Should this be configurable? Note that it should likely be a function of SubmitProofCloseWindowNumBlocks once implemented.
Variables ¶
This section is empty.
Functions ¶
func GetNumBlocksUndelegationRetention ¶ added in v0.0.2
func GetNumBlocksUndelegationRetention(sharedParams *sharedtypes.Params) int64
GetNumBlocksUndelegationRetention returns the number of blocks for which undelegations should be kept before being pruned, given the passed shared module parameters.
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeService store.KVStoreService, logger log.Logger, authority string, bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, gatewayKeeper types.GatewayKeeper, sharedKeeper types.SharedKeeper, ) Keeper
func (Keeper) AllApplications ¶
func (k Keeper) AllApplications(ctx context.Context, req *types.QueryAllApplicationsRequest) (*types.QueryAllApplicationsResponse, error)
func (Keeper) Application ¶
func (k Keeper) Application(ctx context.Context, req *types.QueryGetApplicationRequest) (*types.QueryGetApplicationResponse, error)
func (Keeper) CleanupOrphanedUndelegationIndexes ¶ added in v0.1.33
CleanupOrphanedUndelegationIndexes removes orphaned undelegation index entries that reference applications which no longer exist in the store.
This can occur when an application with pending undelegations is removed (unstaked or transferred) but the undelegation index entries are not properly cleaned up due to a bug in removeApplicationUndelegationIndex that was deleting from the delegation store instead of the undelegation store.
Returns the count of orphaned entries removed and any error.
func (Keeper) EndBlockerAutoUndelegateFromUnbondingGateways ¶ added in v0.0.13
func (k Keeper) EndBlockerAutoUndelegateFromUnbondingGateways(ctx cosmostypes.Context) error
EndBlockerAutoUndelegateFromUnbondingGateways is called every block and handles Application auto-undelegating from unbonding gateways that are no longer active.
func (Keeper) EndBlockerPruneAppToGatewayPendingUndelegation ¶ added in v0.0.2
EndBlockerPruneAppToGatewayPendingUndelegation runs at the end of each block and prunes app to gateway undelegations that have exceeded the retention delay.
func (Keeper) EndBlockerTransferApplication ¶ added in v0.0.10
EndBlockerTransferApplication completes pending application transfers. This always happens on the last block of a session during which the transfer started. It is accomplished by:
- Copying the current state of the source app onto a new destination app
- Unstaking (removing) the source app
- Staking (storing) the destination app
func (Keeper) EndBlockerUnbondApplications ¶ added in v0.0.7
EndBlockerUnbondApplications unbonds applications whose unbonding period has elapsed.
func (Keeper) GetAllApplications ¶
func (k Keeper) GetAllApplications(ctx context.Context) (apps []types.Application)
GetAllApplications returns all applications in the store. - Ensures PendingUndelegations is always initialized
func (Keeper) GetAllApplicationsIterator ¶ added in v0.1.5
func (k Keeper) GetAllApplicationsIterator(ctx context.Context) sharedtypes.RecordIterator[types.Application]
GetAllApplicationsIterator returns a RecordIterator over all Application records. - Uses the main application store and unmarshals each record - Initializes nil fields in each application object
func (Keeper) GetAllTransferringApplicationsIterator ¶ added in v0.1.8
func (k Keeper) GetAllTransferringApplicationsIterator( ctx context.Context, ) sharedtypes.RecordIterator[types.Application]
GetAllTransferringApplicationsIterator returns an iterator over all transferring applications. - Uses transferring applications store as the source of truth - Accesses full application objects via primary key accessor
func (Keeper) GetAllUnstakingApplicationsIterator ¶ added in v0.1.8
func (k Keeper) GetAllUnstakingApplicationsIterator( ctx context.Context, ) sharedtypes.RecordIterator[types.Application]
GetAllUnstakingApplicationsIterator returns an iterator over all unstaking applications. - Uses unstaking applications store as the source of truth - Accesses full application objects via primary key accessor
func (Keeper) GetApplication ¶
func (k Keeper) GetApplication( ctx context.Context, appAddr string, ) (app types.Application, found bool)
GetApplication retrieves an application by address. - Returns false if not found - Initializes PendingUndelegations as an empty map if nil - Initializes DelegateeGatewayAddresses as an empty slice if nil
func (Keeper) GetAuthority ¶
GetAuthority returns the module's authority.
func (Keeper) GetDelegationsIterator ¶ added in v0.1.8
func (k Keeper) GetDelegationsIterator( ctx context.Context, gatewayAddress string, ) sharedtypes.RecordIterator[types.Application]
GetDelegationsIterator returns an iterator for applications delegated to a specific gateway. - Filters delegations by gateway address prefix - Returns only delegations related to the given gateway
func (Keeper) GetNumBlocksUndelegationRetention ¶ added in v0.0.3
GetNumBlocksUndelegationRetention returns the number of blocks for which undelegations should be kept before being pruned, given the current onchain shared module parameters.
func (Keeper) GetUndelegationsIterator ¶ added in v0.1.8
func (k Keeper) GetUndelegationsIterator( ctx context.Context, applicationAddress string, ) sharedtypes.RecordIterator[types.PendingUndelegation]
GetUndelegationsIterator returns an iterator for applications with pending undelegations. - If ALL_UNDELEGATIONS is passed, returns all pending undelegations - Otherwise, filters by application address prefix
func (Keeper) Params ¶
func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
func (Keeper) RemoveApplication ¶
func (k Keeper) RemoveApplication(ctx context.Context, application types.Application)
RemoveApplication deletes an application from the store and all related indexes. - Removes from unstaking, transfer, undelegation, and delegation indexes - Deletes from the main application store
func (Keeper) SetApplication ¶
func (k Keeper) SetApplication(ctx context.Context, application types.Application)
SetApplication sets an application in the store and updates all related indexes. - Indexes the application in all relevant indexes - Stores the application in the main application store
func (Keeper) StakeApplication ¶ added in v0.0.14
func (k Keeper) StakeApplication( ctx context.Context, logger cosmoslog.Logger, msg *types.MsgStakeApplication, ) (_ *types.Application, err error)
StakeApplication stakes (or updates) the application according to the given msg by applying the following logic:
- the msg is validated
- if the application is not found, it is created (in memory) according to the valid msg
- if the application is found and is not unbonding, it is updated (in memory) according to the msg
- if the application is found and is unbonding, it is updated (in memory; and no longer unbonding)
- additional stake validation (e.g. min stake, etc.)
- the positive difference between the msg stake and any current stake is transferred from the staking application's account, to the application module's accounts.
- the (new or updated) application is persisted.
- an EventApplicationUnbondingCanceled event is emitted if the application was unbonding.
- an EventApplicationStaked event is emitted.
func (Keeper) UnbondApplication ¶ added in v0.0.10
UnbondApplication transfers the application stake to the bank module balance for the corresponding account and removes the application from the application module state.
Source Files
¶
- application.go
- application_index.go
- auto_undelegate.go
- keeper.go
- migrate_orphaned_indexes.go
- msg_server.go
- msg_server_delegate_to_gateway.go
- msg_server_stake_application.go
- msg_server_transfer_application.go
- msg_server_undelegate_from_gateway.go
- msg_server_unstake_application.go
- msg_server_update_param.go
- msg_update_params.go
- params.go
- prune_undelegations.go
- query.go
- query_application.go
- query_params.go
- transfer_applications.go
- unbond_applications.go