keeper

package
v1.1.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2024 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMsgServerImpl

func NewMsgServerImpl(keeper *Keeper) types.MsgServer

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

func NewQuerierImpl

func NewQuerierImpl(k *Keeper) types.QueryServer

NewQuerierImpl returns an implementation of the captains QueryServer interface.

Types

type Keeper

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

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	storeKey storetypes.StoreKey,
	paramSpace paramtypes.Subspace,
	stakingKeeper types.StakingKeeper,
	authority sdk.AccAddress,
) Keeper

func (Keeper) AuthorizeNode

func (k Keeper) AuthorizeNode(ctx sdk.Context, nodeID string, owner sdk.AccAddress) error

AuthorizeNode defines a method for checking if the sender is the owner of the given node

func (Keeper) BeginBlocker

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

BeginBlocker called every block, process the epoch if it's ended.

func (Keeper) CalcAndSetNodeCumulativeEmissionByEpoch

func (k Keeper) CalcAndSetNodeCumulativeEmissionByEpoch(ctx sdk.Context, epochID uint64, nodeID string) sdk.Dec

CalcAndSetNodeCumulativeEmissionByEpoch returns the historical emission for a node at the end of an epoch. NOTE: this function set the historical emission by the end of epoch(t) and removes that of epoch(t-1).

func (Keeper) CalcBaseEpochEmission

func (k Keeper) CalcBaseEpochEmission(ctx sdk.Context) sdk.Dec

CalcBaseEpochEmission returns the base emission reward for an epoch.

func (Keeper) CalcEpochEmission

func (k Keeper) CalcEpochEmission(ctx sdk.Context, epochID uint64, globalOperationRatio sdk.Dec) sdk.Dec

CalcEpochEmission returns the total emission reward for an epoch.

func (Keeper) CalcGlobalPledgeRatio

func (k Keeper) CalcGlobalPledgeRatio(ctx sdk.Context, epochID uint64) sdk.Dec

CalcGlobalPledgeRatio calculates the pledge rate of the global on the epoch t.

func (Keeper) CalcNodeComputingPowerOnEpoch

func (k Keeper) CalcNodeComputingPowerOnEpoch(
	ctx sdk.Context,
	epochID uint64,
	nodeID string,
	powerOnRatio sdk.Dec,
) sdk.Dec

CalcNodeComputingPowerOnEpoch returns the computing power of a node as per its node info.

func (Keeper) CalcNodeCumulativeEmissionByEpoch

func (k Keeper) CalcNodeCumulativeEmissionByEpoch(ctx sdk.Context, epochID uint64, nodeID string) sdk.Dec

CalcNodeCumulativeEmissionByEpoch returns the historical emission for a node at the end of an epoch. NOTE: this func is only used to query and it won't set or prune state data.

func (Keeper) CalcNodeEmissionOnEpoch

func (k Keeper) CalcNodeEmissionOnEpoch(ctx sdk.Context, epochID uint64, nodeID string) sdk.Dec

CalcNodeEmissionOnEpoch returns the emission for a node at the end of an epoch.

func (Keeper) CalcNodePledgeRatioOnEpoch

func (k Keeper) CalcNodePledgeRatioOnEpoch(ctx sdk.Context, epochID uint64, nodeID string) sdk.Dec

CalcNodePledgeRatioOnEpoch calculates the pledge rate of the node on the epoch t but also prune pledge 2 epochs before.

func (Keeper) CalcTechProgressCoefficient

func (k Keeper) CalcTechProgressCoefficient(ctx sdk.Context) sdk.Dec

CalcTechProgressCoefficient calculates tech progress coefficient TechProgressCoefficient = 1.6 ^ (captainNodeSaleLevel - 1)

func (Keeper) CommitComputingPower

func (k Keeper) CommitComputingPower(ctx sdk.Context, amount uint64, owner sdk.AccAddress) (uint64, uint64)

CommitComputingPower commits the pending computing power.

func (Keeper) CommitReport

func (k Keeper) CommitReport(ctx sdk.Context, report any) error

CommitReport processes a report

func (Keeper) CreateNode

func (k Keeper) CreateNode(
	ctx sdk.Context,
	divisionID string,
	owner sdk.AccAddress,
) (string, error)

CreateNode defines a method for create a new node for owner.

func (Keeper) DecideDivision

func (k Keeper) DecideDivision(ctx sdk.Context, power uint64) types.Division

DecideDivision decides the division of the node as per power.

func (Keeper) DelGlobalPledge

func (k Keeper) DelGlobalPledge(ctx sdk.Context, epochID uint64)

DelGlobalPledge deletes the total pledge amount of captains' owners on the epoch end.

func (Keeper) DeleteAuthorizedMembers

func (k Keeper) DeleteAuthorizedMembers(ctx sdk.Context, members []string) error

DeleteAuthorizedMembers deletes the list of authorized members

func (Keeper) EndBlocker

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

EndBlocker called every block, process the report digest if exists.

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

ExportGenesis returns a GenesisState for a given context and keeper.

func (Keeper) GenerateNodeID

func (k Keeper) GenerateNodeID(ctx sdk.Context) string

GenerateNodeID defines a method for generating a new node id

func (Keeper) GetAuthorizedMembers

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

GetAuthorizedMembers returns the list of authorized members

func (Keeper) GetBaseState

func (k Keeper) GetBaseState(ctx sdk.Context) types.BaseState

GetBaseState returns the base state of the current epoch.

func (Keeper) GetCaptainsConstant

func (k Keeper) GetCaptainsConstant(ctx sdk.Context) sdk.Dec

GetCaptainsConstant returns the captains constant

func (Keeper) GetClaimableComputingPower

func (k Keeper) GetClaimableComputingPower(ctx sdk.Context, owner sdk.AccAddress) uint64

GetClaimableComputingPower returns the claimable computing power of an owner.

func (Keeper) GetClaimableComputingPowers

func (k Keeper) GetClaimableComputingPowers(ctx sdk.Context) []types.ClaimableComputingPower

GetClaimableComputingPowers returns all claimable computing powers.

func (Keeper) GetCurrentEpoch

func (k Keeper) GetCurrentEpoch(ctx sdk.Context) uint64

GetCurrentEpoch returns the current epoch.

func (Keeper) GetDivision

func (k Keeper) GetDivision(ctx sdk.Context, divisionID string) (types.Division, bool)

GetDivision returns the division by the specified division ID

func (Keeper) GetDivisions

func (k Keeper) GetDivisions(ctx sdk.Context) (divisions []types.Division)

GetDivisions returns all divisions

func (Keeper) GetEpochEmission

func (k Keeper) GetEpochEmission(ctx sdk.Context, epochID uint64) sdk.Dec

GetEpochEmission returns the emission reward for an epoch.

func (Keeper) GetEpochesEmission

func (k Keeper) GetEpochesEmission(ctx sdk.Context) []types.EpochEmission

GetEpochesEmission sets the emission reward for an epoch.

func (Keeper) GetGlobalClaimedEmission

func (k Keeper) GetGlobalClaimedEmission(ctx sdk.Context) sdk.Dec

GetGlobalClaimedEmission returns global claimed emission.

func (Keeper) GetGlobalComputingPowerOnEpoch

func (k Keeper) GetGlobalComputingPowerOnEpoch(ctx sdk.Context, epochID uint64) sdk.Dec

GetGlobalComputingPowerOnEpoch returns the sum of computing power of all nodes.

func (Keeper) GetGlobalPledge

func (k Keeper) GetGlobalPledge(ctx sdk.Context, epochID uint64) sdk.Dec

GetGlobalPledge returns the total pledge amount of one epoch end.

func (Keeper) GetGlobalsComputingPower

func (k Keeper) GetGlobalsComputingPower(ctx sdk.Context) []types.GlobalComputingPower

GetGlobalsComputingPower returns all global computing power.

func (Keeper) GetGlobalsPledge

func (k Keeper) GetGlobalsPledge(ctx sdk.Context) []types.GlobalPledge

GetGlobalsPledge returns all global pledge.

func (Keeper) GetHalvingEraCoefficient

func (k Keeper) GetHalvingEraCoefficient(ctx sdk.Context) sdk.Dec

GetHalvingEraCoefficient returns the tech progress coefficient

func (Keeper) GetLastNodeID

func (k Keeper) GetLastNodeID(ctx sdk.Context) string

GetLastNodeID defines a method for returning the last node id

func (Keeper) GetNode

func (k Keeper) GetNode(ctx sdk.Context, nodeID string) (types.Node, bool)

GetNode defines a method for returning the node information of the specified id

func (Keeper) GetNodeBaseComputingPower

func (k Keeper) GetNodeBaseComputingPower(ctx sdk.Context, nodeID string) uint64

GetNodeBaseComputingPower returns the base computing power of a node as per its node info.

func (Keeper) GetNodeClaimedEmission

func (k Keeper) GetNodeClaimedEmission(ctx sdk.Context, nodeID string) sdk.Dec

GetNodeClaimedEmission returns the claimed emission of a node.

func (Keeper) GetNodeComputingPowerOnEpoch

func (k Keeper) GetNodeComputingPowerOnEpoch(ctx sdk.Context, epochID uint64, nodeID string) sdk.Dec

GetNodeComputingPowerOnEpoch returns the computing power of a node as per its node info.

func (Keeper) GetNodeCumulativeEmissionByEpoch

func (k Keeper) GetNodeCumulativeEmissionByEpoch(ctx sdk.Context, epochID uint64, nodeID string) sdk.Dec

GetNodeCumulativeEmissionByEpoch returns the historical emission for a node at the end of an epoch.

func (Keeper) GetNodeOwner

func (k Keeper) GetNodeOwner(ctx sdk.Context, nodeID string) (sdk.AccAddress, bool)

GetNodeOwner returns the owner of the specified node

func (Keeper) GetNodeSequence

func (k Keeper) GetNodeSequence(ctx sdk.Context) uint64

GetNodeSequence gets the next Node sequence from the store.

func (Keeper) GetNodes

func (k Keeper) GetNodes(ctx sdk.Context) (nodes []types.Node)

GetNodes returns all nodes

func (Keeper) GetNodesByOwner

func (k Keeper) GetNodesByOwner(ctx sdk.Context, owner sdk.AccAddress) (nodes []types.Node)

GetNodesByOwner return all nodes owned by the specified owner

func (Keeper) GetNodesClaimedEmission

func (k Keeper) GetNodesClaimedEmission(ctx sdk.Context) []types.NodeClaimedEmission

GetNodesClaimedEmission returns the claimed emission of all nodes.

func (Keeper) GetNodesComputingPower

func (k Keeper) GetNodesComputingPower(ctx sdk.Context) []types.NodesComputingPower

GetNodesComputingPower returns all nodes computing power.

func (Keeper) GetNodesCount

func (k Keeper) GetNodesCount(ctx sdk.Context) uint64

GetNodesCount returns the total number of nodes

func (Keeper) GetNodesCumulativeEmission

func (k Keeper) GetNodesCumulativeEmission(ctx sdk.Context) []types.NodeCumulativeEmission

GetNodesCumulativeEmission returns the cumulative emission of all nodes.

func (Keeper) GetOwnerClaimedEmission

func (k Keeper) GetOwnerClaimedEmission(ctx sdk.Context, owner sdk.AccAddress) sdk.Dec

GetOwnerClaimedEmission returns the historical emission the last time user claimed.

func (Keeper) GetOwnerPledge

func (k Keeper) GetOwnerPledge(ctx sdk.Context, owner sdk.AccAddress, epochID uint64) sdk.Dec

GetOwnerPledge returns the sampled pledge amount of the owner on the epoch.

func (Keeper) GetOwnersPledge

func (k Keeper) GetOwnersPledge(ctx sdk.Context) []types.OwnerPledge

GetOwnersPledge returns all owner pledge.

func (Keeper) GetParams

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

GetParams sets the captains module parameters.

func (Keeper) GetReportBatches

func (k Keeper) GetReportBatches(ctx sdk.Context, epochID uint64) []types.BatchBase

GetReportBatches returns the batch count.

func (Keeper) GetReportDigest

func (k Keeper) GetReportDigest(ctx sdk.Context, epochID uint64) (*types.ReportDigest, bool)

GetReportDigest returns the digest.

func (Keeper) GetSaleLevel

func (k Keeper) GetSaleLevel(ctx sdk.Context) uint64

GetSaleLevel returns the current sale level.

func (Keeper) HandleReportBatch

func (k Keeper) HandleReportBatch(ctx sdk.Context, report *types.ReportBatch) error

HandleReportBatch processes a report batch

func (Keeper) HandleReportDigest

func (k Keeper) HandleReportDigest(ctx sdk.Context, report *types.ReportDigest) error

HandleReportDigest processes a report digest

NOTE: Part of handle logic are delayed to the end blocker. This is because we may encounter multiple params update in the same block which affect the calculation.

func (Keeper) HandleReportEnd

func (k Keeper) HandleReportEnd(ctx sdk.Context, report *types.ReportEnd) error

HandleReportEnd processes a report end

func (Keeper) HasAuthorizedMember

func (k Keeper) HasAuthorizedMember(ctx sdk.Context, member sdk.AccAddress) bool

HasAuthorizedMember asserts whether an address is in authorized member lists.

func (Keeper) HasDivision

func (k Keeper) HasDivision(ctx sdk.Context, divisionID string) bool

HasDivision checks if the division exists in the store

func (Keeper) HasEndEpoch

func (k Keeper) HasEndEpoch(ctx sdk.Context, epochID uint64) bool

HasEndEpoch checks if the end epoch exists.

func (Keeper) HasEpochEmission

func (k Keeper) HasEpochEmission(ctx sdk.Context, epochID uint64) bool

HasEpochEmission returns if the emission reward for an epoch exists.

func (Keeper) HasGlobalPledge

func (k Keeper) HasGlobalPledge(ctx sdk.Context, epochID uint64) bool

func (Keeper) HasNode

func (k Keeper) HasNode(ctx sdk.Context, nodeID string) bool

HasNode defines a method for checking the existence of a node

func (Keeper) HasNodeComputingPowerOnEpoch

func (k Keeper) HasNodeComputingPowerOnEpoch(ctx sdk.Context, epochID uint64, nodeID string) bool

HasNodeComputingPowerOnEpoch checks if the node has computing power on the epoch.

func (Keeper) HasNodeCumulativeEmissionByEpoch

func (k Keeper) HasNodeCumulativeEmissionByEpoch(ctx sdk.Context, epochID uint64, nodeID string) bool

HasNodeCumulativeEmissionByEpoch returns if the historical emission for a node at the end of an epoch exists.

func (Keeper) HasOwnerPledge

func (k Keeper) HasOwnerPledge(ctx sdk.Context, owner sdk.AccAddress, epochID uint64) bool

HasOwnerPledge checks if the owner has the sampled pledge amount on the epoch.

func (Keeper) HasReportBatch

func (k Keeper) HasReportBatch(ctx sdk.Context, epochID, batchID uint64) bool

HasReportBatch checks if the batch exists.

func (Keeper) HasReportDigest

func (k Keeper) HasReportDigest(ctx sdk.Context, epochID uint64) bool

HasReportDigest checks if the digest exists.

func (Keeper) HasStandByOverFlag

func (k Keeper) HasStandByOverFlag(ctx sdk.Context) bool

HasStandByOverFlag checks if the stand by flag exists.

func (Keeper) IncrGlobalPledge

func (k Keeper) IncrGlobalPledge(ctx sdk.Context, epochID uint64, amount sdk.Dec)

IncrGlobalPledge increments the total pledge amount of captains' owners on the epoch end.

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState)

InitGenesis stores the NFT genesis.

func (Keeper) IsReportCompleted

func (k Keeper) IsReportCompleted(ctx sdk.Context, epochId uint64) error

IsReportCompleted checks if the report is completed

func (Keeper) IsStandByPhase

func (k Keeper) IsStandByPhase(ctx sdk.Context) bool

IsStandByPhase checks if the stand by phrase is active.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) SampleOwnerPledge

func (k Keeper) SampleOwnerPledge(ctx sdk.Context, owner sdk.AccAddress) (sdk.Dec, error)

SampleOwnerPledge sample pledge amount of the owner on the epoch.

func (Keeper) SaveDivision

func (k Keeper) SaveDivision(ctx sdk.Context, division types.Division) error

SaveDivision saves a division to the store

func (Keeper) SetAuthorizedMembers

func (k Keeper) SetAuthorizedMembers(ctx sdk.Context, members []string) error

SetAuthorizedMembers sets the list of authorized members

func (Keeper) SetBaseState

func (k Keeper) SetBaseState(ctx sdk.Context, bs *types.BaseState)

SetBaseState sets the base state of the current epoch.

func (Keeper) SetGlobalClaimedEmission

func (k Keeper) SetGlobalClaimedEmission(ctx sdk.Context, amount sdk.Dec)

SetGlobalClaimedEmission sets global claimed emission.

func (Keeper) SetGlobalPledge

func (k Keeper) SetGlobalPledge(ctx sdk.Context, epochID uint64, sum sdk.Dec)

SetGlobalPledge sets the total pledge amount of captains' owners on the epoch end.

func (Keeper) SetNodeClaimedEmission

func (k Keeper) SetNodeClaimedEmission(ctx sdk.Context, nodeID string, amount sdk.Dec)

SetNodeClaimedEmission sets the historical emission the last time user claimed.

func (Keeper) SetNodeSequence

func (k Keeper) SetNodeSequence(ctx sdk.Context, sequence uint64)

SetNodeSequence sets the next Node sequence to the store.

func (Keeper) SetOwnerPledge

func (k Keeper) SetOwnerPledge(ctx sdk.Context, owner sdk.AccAddress, epochID uint64, pledge sdk.Dec)

SetOwnerPledge sets the sampled pledge amount of the owner on the epoch.

func (Keeper) SetParams

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

SetParams sets the captains module parameters.

func (Keeper) UpdateGlobalAndNodeClaimedEmission

func (k Keeper) UpdateGlobalAndNodeClaimedEmission(ctx sdk.Context, nodeID string) error

UpdateGlobalAndNodeClaimedEmission updates node's claimed emission and incr global claimed emission. NOTE: call this function only after claiming the rewards.

func (Keeper) UpdateNode

func (k Keeper) UpdateNode(
	ctx sdk.Context,
	nodeID string,
	amount uint64,
	owner sdk.AccAddress,
) error

UpdateNode defines a method for updating the computing power of the specified node

func (Keeper) UpdateSaleLevel

func (k Keeper) UpdateSaleLevel(ctx sdk.Context, newSaleLevel uint64) (uint64, error)

UpdateSaleLevel updates the sale level in params.

func (Keeper) ValidateReport

func (k Keeper) ValidateReport(ctx sdk.Context, reportType types.ReportType, report *sdkcdc.Any) (any, error)

ValidateReport checks if the report is valid

func (Keeper) ValidateReportBatch

func (k Keeper) ValidateReportBatch(ctx sdk.Context, report *types.ReportBatch) error

ValidateReportBatch checks if the report batch is valid

func (Keeper) ValidateReportDigest

func (k Keeper) ValidateReportDigest(ctx sdk.Context, report *types.ReportDigest) error

ValidateReportDigest checks if the report digest is valid

func (Keeper) ValidateReportEnd

func (k Keeper) ValidateReportEnd(ctx sdk.Context, report *types.ReportEnd) error

ValidateReportEnd checks if the report end is valid

func (Keeper) ValidateReportEpoch

func (k Keeper) ValidateReportEpoch(ctx sdk.Context, epochID uint64) error

ValidateReportEpoch checks if the report is valid

type Querier

type Querier struct {
	*Keeper
}

func (Querier) AuthorizedMembers

AuthorizedMembers queries the list of authorized members

func (Querier) CurrentEpoch

CurrentEpoch queries current epoch and its block height.

func (Querier) Division

Division queries an node division by its ID

func (Querier) Divisions

Divisions queries all Node divisions

func (Querier) EpochStatus

EpochStatus queries the status of an epoch.

func (Querier) Node

func (q Querier) Node(
	goCtx context.Context,
	request *types.QueryNodeRequest,
) (*types.QueryNodeResponse, error)

Node queries a Node.

func (Querier) NodeLastEpochInfo

NodeLastEpochInfo queries the last epoch info of a node

func (Querier) Nodes

func (q Querier) Nodes(
	goCtx context.Context,
	request *types.QueryNodesRequest,
) (*types.QueryNodesResponse, error)

Nodes queries all node of a given owner

func (Querier) Params

Params queries the captains module parameters

func (Querier) SaleLevel

SaleLevel queries the current sale level

func (Querier) Supply

func (q Querier) Supply(
	goCtx context.Context,
	request *types.QuerySupplyRequest,
) (*types.QuerySupplyResponse, error)

Supply queries the number of Node from the given division

Jump to

Keyboard shortcuts

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