keeper

package
v0.0.0-...-21d70e9 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AATGeneration

func AATGeneration(appPubKey, clientPubKey string, appPrivKey crypto.PrivateKey) (pc.AAT, sdk.Error)

GenerateAAT generates an AAT to be used for relay request authentication. - appPubKey is the public key of the application that's staking for on-chain service. - clientPubKey is the public key of a client facilitating relays on behalf of the app. - appPubKey and clientPubKey may or may not be the same.

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

"NewQuerier" - Creates an sdk.Querier for the pocket core module

func ParamKeyTable

func ParamKeyTable() sdk.KeyTable

"ParamKeyTable" - Registers the paramset types in a keytable and returns the table

Types

type Keeper

type Keeper struct {
	TmNode client.Client

	Paramstore sdk.Subspace

	Cdc *codec.Codec // The wire codec for binary encoding/decoding.
	// contains filtered or unexported fields
}

Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(storeKey sdk.StoreKey, cdc *codec.Codec, authKeeper types.AuthKeeper, posKeeper types.PosKeeper, appKeeper types.AppsKeeper, hostedChains *types.HostedBlockchains, paramstore sdk.Subspace) Keeper

NewKeeper creates new instances of the pocketcore module Keeper

func (Keeper) AwardCoinsForRelays

func (k Keeper) AwardCoinsForRelays(
	ctx sdk.Ctx,
	chain string,
	relays int64,
	toAddr sdk.Address,
) sdk.BigInt

"AwardCoinsForRelays" - Award coins to nodes for relays completed using the nodes keeper

func (Keeper) BlockByteSize

func (k Keeper) BlockByteSize(ctx sdk.Ctx) (res int64)

BlockByteSize - Returns the block byte size parameter from the paramstore governing the maximum size of each block

func (Keeper) BlocksPerSession

func (k Keeper) BlocksPerSession(ctx sdk.Ctx) int64

"BlocksPerSession" - Returns blocksPerSession parameter from the paramstore How many blocks per session

func (Keeper) BurnCoinsForChallenges

func (k Keeper) BurnCoinsForChallenges(ctx sdk.Ctx, relays int64, toAddr sdk.Address)

"BurnCoinsForChallenges" - Executes the burn for challenge function in the nodes module

func (Keeper) ClaimExpiration

func (k Keeper) ClaimExpiration(ctx sdk.Ctx) (res int64)

"ClaimExpiration" - Returns the claim expiration parameter from the paramstore Number of sessions pass before claim is expired

func (Keeper) ClaimIsMature

func (k Keeper) ClaimIsMature(ctx sdk.Ctx, sessionBlockHeight int64) bool

"ClaimIsMature" - Returns if the claim is past its security waiting period

func (Keeper) ClaimSubmissionWindow

func (k Keeper) ClaimSubmissionWindow(ctx sdk.Ctx) (res int64)

"ClaimSubmissionWindow" - Returns claimSubmissionWindow parameter from the paramstore How long do you have to submit a claim before the secret is revealed and it's invalid

func (Keeper) ClearSessionCache

func (Keeper) ClearSessionCache()

func (Keeper) Codec

func (k Keeper) Codec() *codec.Codec

func (Keeper) ConsensusParamUpdate

func (k Keeper) ConsensusParamUpdate(ctx sdk.Ctx) *abci.ConsensusParams

func (Keeper) ConvertState

func (k Keeper) ConvertState(ctx sdk.Ctx)

func (Keeper) DeleteClaim

func (k Keeper) DeleteClaim(ctx sdk.Ctx, address sdk.Address, header pc.SessionHeader, evidenceType pc.EvidenceType) error

"DeleteClaim" - Removes a claim object for a certain key

func (Keeper) DeleteExpiredClaims

func (k Keeper) DeleteExpiredClaims(ctx sdk.Ctx)

"DeleteExpiredClaims" - Deletes the expired (claim expiration > # of session passed since claim genesis) claims

func (Keeper) ExecuteProof

func (k Keeper) ExecuteProof(ctx sdk.Ctx, proof pc.MsgProof, claim pc.MsgClaim) (tokens sdk.BigInt, err sdk.Error)

func (Keeper) GetAllClaims

func (k Keeper) GetAllClaims(ctx sdk.Ctx) (claims []pc.MsgClaim)

"GetAllClaims" - Gets all of the claim messages held in the state storage.

func (Keeper) GetApp

func (k Keeper) GetApp(ctx sdk.Ctx, address sdk.Address) (a exported.ApplicationI, found bool)

"GetApp" - Retrieves an application from the app store, using the appKeeper (a link to the apps module)

func (Keeper) GetAppFromPublicKey

func (k Keeper) GetAppFromPublicKey(ctx sdk.Ctx, pubKey string) (app exported.ApplicationI, found bool)

"GetAppFromPublicKey" - Retrieves an application from the app store, using the appKeeper (a link to the apps module) using a hex string public key

func (Keeper) GetAppStakedTokens

func (k Keeper) GetAppStakedTokens(ctx sdk.Ctx) (res sdk.BigInt)

"GetAppStakedTokens" - Returns the total number of staked tokens in the apps module

func (Keeper) GetBlock

func (k Keeper) GetBlock(height int) (*coretypes.ResultBlock, error)

"GetBlock" returns the block from the tendermint node at a certain height

func (Keeper) GetClaim

func (k Keeper) GetClaim(ctx sdk.Ctx, address sdk.Address, header pc.SessionHeader, evidenceType pc.EvidenceType) (msg pc.MsgClaim, found bool)

"GetClaim" - Retrieves the claim message from the store, requires the evidence type and header to return the proper claim message

func (Keeper) GetClaims

func (k Keeper) GetClaims(ctx sdk.Ctx, address sdk.Address) (claims []pc.MsgClaim, err error)

"GetClaims" - Gets all of the claim messages in the state storage for an address

func (Keeper) GetHostedBlockchains

func (k Keeper) GetHostedBlockchains() *pc.HostedBlockchains

"GetHostedBlockchains" returns the non native chains hosted locally on this node

func (Keeper) GetLatestSessionBlockHeight

func (k Keeper) GetLatestSessionBlockHeight(ctx sdk.Ctx) (sessionBlockHeight int64)

"GetLatestSessionBlockHeight" - Returns the latest session block height (first block of the session, (see blocksPerSession))

func (Keeper) GetMatureClaims

func (k Keeper) GetMatureClaims(ctx sdk.Ctx, address sdk.Address) (matureProofs []pc.MsgClaim, err error)

"GetMatureClaims" - Returns the mature (ready to be proved, past its security waiting period)

func (Keeper) GetNode

func (k Keeper) GetNode(ctx sdk.Ctx, address sdk.Address) (n exported.ValidatorI, found bool)

"GetNode" - Gets a node from the state storage

func (Keeper) GetNodesStakedTokens

func (k Keeper) GetNodesStakedTokens(ctx sdk.Ctx) (res sdk.BigInt)

"GetNodeStakedTokens" - Returns the total number of staked tokens in the nodes module

func (Keeper) GetParams

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

"GetParams" - Returns all module parameters in a `Params` struct

func (Keeper) GetTotalStakedTokens

func (k Keeper) GetTotalStakedTokens(ctx sdk.Ctx) (res sdk.BigInt)

"GetTotalStakedTokens" - Returns the summation of app staked tokens and node staked tokens

func (Keeper) GetTotalTokens

func (k Keeper) GetTotalTokens(ctx sdk.Ctx) (res sdk.BigInt)

"GetTotalTokens" - Returns the total number of tokens kept in any/all modules

func (Keeper) HandleChallenge

func (k Keeper) HandleChallenge(ctx sdk.Ctx, challenge pc.ChallengeProofInvalidData) (*pc.ChallengeResponse, sdk.Error)

"HandleChallenge" - Handles a client relay response challenge request

func (Keeper) HandleDispatch

func (k Keeper) HandleDispatch(ctx sdk.Ctx, header types.SessionHeader) (*types.DispatchResponse, sdk.Error)

"HandleDispatch" - Handles a client request for their session information

func (Keeper) HandleRelay

func (k Keeper) HandleRelay(ctx sdk.Ctx, relay pc.Relay) (*pc.RelayResponse, sdk.Error)

HandleRelay handles an api (read/write) request to a non-native (external) blockchain

func (Keeper) HandleReplayAttack

func (k Keeper) HandleReplayAttack(ctx sdk.Ctx, address sdk.Address, numberOfChallenges sdk.BigInt)

func (Keeper) IsPocketSupportedBlockchain

func (k Keeper) IsPocketSupportedBlockchain(ctx sdk.Ctx, chain string) bool

"IsPocketSupportedBlockchain" - Returns true if network identifier param is supported by pocket

func (Keeper) IsProofSessionHeightWithinTolerance

func (k Keeper) IsProofSessionHeightWithinTolerance(ctx sdk.Ctx, relaySessionBlockHeight int64) bool

IsProofSessionHeightWithinTolerance checks if the relaySessionBlockHeight is bounded by (latestSessionBlockHeight - tolerance ) <= x <= latestSessionHeight

func (Keeper) IsSessionBlock

func (k Keeper) IsSessionBlock(ctx sdk.Ctx) bool

"IsSessionBlock" - Returns true if current block, is a session block (beginning of a session)

func (Keeper) MinimumNumberOfProofs

func (k Keeper) MinimumNumberOfProofs(ctx sdk.Ctx) (res int64)

"MinimumNumberOfProofs" - Returns a minimun number of proofs parameter from the paramstore What blockchains are supported in pocket network (list of network identifier hashes)

func (Keeper) ReplayAttackBurnMultiplier

func (k Keeper) ReplayAttackBurnMultiplier(ctx sdk.Ctx) (res int64)

"ReplayAttackBurn" - Returns the replay attack burn parameter from the paramstore The multiplier for how heavily nodes are burned for replay attacks

func (Keeper) SendClaimTx

func (k Keeper) SendClaimTx(
	ctx sdk.Ctx,
	keeper Keeper,
	n client.Client,
	node *pc.PocketNode,
	claimTx func(pk crypto.PrivateKey, cliCtx util.CLIContext, txBuilder auth.TxBuilder, header pc.SessionHeader, totalProofs int64, root pc.HashRange, evidenceType pc.EvidenceType) (*sdk.TxResponse, error),
)

"SendClaimTx" - Automatically sends a claim of work/challenge based on relays or challenges stored.

func (Keeper) SendProofTx

func (k Keeper) SendProofTx(ctx sdk.Ctx, n client.Client, node *pc.PocketNode, proofTx func(cliCtx util.CLIContext, txBuilder auth.TxBuilder, merkleProof pc.MerkleProof, leafNode pc.Proof, evidenceType pc.EvidenceType) (*sdk.TxResponse, error))

SendProofTx auto sends a proof transaction for the claim

func (Keeper) SessionNodeCount

func (k Keeper) SessionNodeCount(ctx sdk.Ctx) (res int64)

"SessionNodeCount" - Returns the session node count parameter from the paramstore Number of nodes dispatched in a single session

func (Keeper) SetClaim

func (k Keeper) SetClaim(ctx sdk.Ctx, msg pc.MsgClaim) error

"SetClaim" - Sets the claim message in the state storage

func (Keeper) SetClaims

func (k Keeper) SetClaims(ctx sdk.Ctx, claims []pc.MsgClaim)

"SetClaims" - Sets all the claim messages in the state storage. (Needed for genesis initializing)

func (Keeper) SetHostedBlockchains

func (k Keeper) SetHostedBlockchains(m map[string]pc.HostedBlockchain) *pc.HostedBlockchains

func (Keeper) SetParams

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

"SetParams" - Sets all of the parameters in the paramstore using the params structure

func (Keeper) StakeDenom

func (k Keeper) StakeDenom(ctx sdk.Ctx) (res string)

"StakeDenom" - Returns the stake coin denomination from the node module

func (Keeper) SupportedBlockchains

func (k Keeper) SupportedBlockchains(ctx sdk.Ctx) (res []string)

"SupportedBlockchains" - Returns a supported blockchain parameter from the paramstore What blockchains are supported in pocket network (list of network identifier hashes)

func (Keeper) UpgradeCodec

func (k Keeper) UpgradeCodec(ctx sdk.Ctx)

func (Keeper) ValidateClaim

func (k Keeper) ValidateClaim(ctx sdk.Ctx, claim pc.MsgClaim) (err sdk.Error)

"ValidateClaim" - Validates a claim message and returns an sdk error if invalid

func (Keeper) ValidateProof

func (k Keeper) ValidateProof(ctx sdk.Ctx, proof pc.MsgProof) (servicerAddr sdk.Address, claim pc.MsgClaim, sdkError sdk.Error)

Jump to

Keyboard shortcuts

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