keeper

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ONE_DAY    = 24 * time.Hour
	TWO_DAYS   = 2 * 24 * time.Hour
	THREE_DAYS = 3 * 24 * time.Hour
)

Variables

This section is empty.

Functions

func GetSlashPercentageAndJailDuration

func GetSlashPercentageAndJailDuration(category types.DisputeCategory) (math.Int, uint64, error)

Get percentage of slash amount based on category, returned as fixed6

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func Ratio

func Ratio(total, part math.Int) math.Int

The `Ratio` function calculates the percentage ratio of `part` to `total`, scaled by a factor of 4 for the total before calculation. The result is expressed as a percentage. Ratio gets called on each sector of voters after votes have been summed e.g Ratio(totalUserTips, userVoteSum)

Types

type DisputesIndex

type DisputesIndex struct {
	DisputeByReporter *indexes.Multi[[]byte, uint64, types.Dispute]
	OpenDisputes      *indexes.Multi[bool, uint64, types.Dispute]
	PendingExecution  *indexes.Multi[bool, uint64, types.Dispute] // New index for PendingExecution
}

func NewDisputesIndex

func NewDisputesIndex(sb *collections.SchemaBuilder) DisputesIndex

func (DisputesIndex) IndexesList

func (a DisputesIndex) IndexesList() []collections.Index[uint64, types.Dispute]

type Keeper

type Keeper struct {
	Params collections.Item[types.Params]

	Disputes                           *collections.IndexedMap[uint64, types.Dispute, DisputesIndex] // dispute id -> dispute
	Votes                              collections.Map[uint64, types.Vote]
	Voter                              *collections.IndexedMap[collections.Pair[uint64, []byte], types.Voter, VotersVoteIndex]
	TeamVoter                          collections.Map[uint64, bool]
	UsersGroup                         collections.Map[collections.Pair[uint64, []byte], math.Int]
	ReportersGroup                     collections.Map[collections.Pair[uint64, []byte], math.Int]
	ReportersWithDelegatorsVotedBefore collections.Map[collections.Pair[[]byte, uint64], math.Int]
	BlockInfo                          collections.Map[[]byte, types.BlockInfo]
	DisputeFeePayer                    collections.Map[collections.Pair[uint64, []byte], types.PayerInfo]
	// dust is extra tokens leftover after truncating decimals, stored as fixed256x12
	Dust              collections.Item[math.Int]
	VoteCountsByGroup collections.Map[uint64, types.StakeholderVoteCounts]
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	oracleKeeper types.OracleKeeper,
	reporterKeeper types.ReporterKeeper,
) Keeper

func (Keeper) AddDisputeRound

func (k Keeper) AddDisputeRound(ctx sdk.Context, sender sdk.AccAddress, dispute types.Dispute, msg types.MsgProposeDispute) error

Update existing dispute when conditions are met

func (Keeper) AddReporterVoteCount

func (k Keeper) AddReporterVoteCount(ctx context.Context, id, amount uint64, choice types.VoteEnum) error

func (Keeper) CalculateReward

func (k Keeper) CalculateReward(ctx sdk.Context, addr sdk.AccAddress, id uint64) (math.Int, error)

func (Keeper) ClaimReward

func (k Keeper) ClaimReward(ctx sdk.Context, addr sdk.AccAddress, id uint64) error

Pay fee from account

func (Keeper) CloseDispute

func (k Keeper) CloseDispute(ctx context.Context, id uint64) error

close dispute by id

func (Keeper) ExecuteVote

func (k Keeper) ExecuteVote(ctx context.Context, id uint64) error

Execute the transfer of fee after the vote on a dispute is complete

func (Keeper) GetAccountBalance

func (k Keeper) GetAccountBalance(ctx context.Context, addr sdk.AccAddress) (math.Int, error)

func (Keeper) GetDisputeByReporter

func (k Keeper) GetDisputeByReporter(ctx sdk.Context, r oracletypes.MicroReport, c types.DisputeCategory) (types.Dispute, error)

Get dispute by reporter key

func (Keeper) GetDisputeFee

func (k Keeper) GetDisputeFee(ctx sdk.Context, rep oracletypes.MicroReport, category types.DisputeCategory) (math.Int, error)

Get dispute fee

func (Keeper) GetOpenDisputes

func (k Keeper) GetOpenDisputes(ctx context.Context) ([]uint64, error)

gets all open disputes

func (Keeper) GetSumOfAllGroupVotesAllRounds

func (k Keeper) GetSumOfAllGroupVotesAllRounds(ctx context.Context, id uint64) (math.Int, error)

func (Keeper) GetTeamAddress

func (k Keeper) GetTeamAddress(ctx context.Context) (sdk.AccAddress, error)

func (Keeper) GetTotalSupply

func (k Keeper) GetTotalSupply(ctx context.Context) math.Int

Get total trb supply

func (Keeper) GetUserTotalTips

func (k Keeper) GetUserTotalTips(ctx context.Context, voter sdk.AccAddress, blockNumber uint64) (math.Int, error)

func (Keeper) GetVoters

func (Keeper) HashId

Generate hash id

func (Keeper) InitVoterClasses

func (k Keeper) InitVoterClasses() *types.VoterClasses

func (Keeper) JailReporter

func (k Keeper) JailReporter(ctx context.Context, repAddr sdk.AccAddress, jailDuration uint64) error

func (Keeper) Logger

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

func (Keeper) NextDisputeId

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

Get next dispute id

func (Keeper) PayDisputeFee

func (k Keeper) PayDisputeFee(ctx sdk.Context, proposer sdk.AccAddress, fee sdk.Coin, fromBond bool, hashId []byte) error

Pay dispute fee

func (Keeper) PayFromAccount

func (k Keeper) PayFromAccount(ctx sdk.Context, addr sdk.AccAddress, fee sdk.Coin) error

Pay fee from account

func (Keeper) PayFromBond

func (k Keeper) PayFromBond(ctx sdk.Context, reporterAddr sdk.AccAddress, fee sdk.Coin, hashId []byte) error

Pay fee from validator's bond can only be called by the validator itself

func (Keeper) RefundDisputeFee

func (k Keeper) RefundDisputeFee(ctx context.Context, feePayer sdk.AccAddress, payerInfo types.PayerInfo, totalFeesPaid, feeMinusBurn math.Int, hashId []byte) (math.Int, error)

func (Keeper) ReporterKey

Make a reporter key by combining reporter address and a hash of dispute params

func (Keeper) ReturnFeetoStake

func (k Keeper) ReturnFeetoStake(ctx context.Context, hashId []byte, remainingAmt math.Int) error

func (Keeper) ReturnSlashedTokens

func (k Keeper) ReturnSlashedTokens(ctx context.Context, dispute types.Dispute) error

return slashed tokens when reporter either wins dispute or dispute is invalid

func (Keeper) RewardReporterBondToFeePayers

func (k Keeper) RewardReporterBondToFeePayers(ctx context.Context, feePayer sdk.AccAddress, payerInfo types.PayerInfo, totalFeesPaid, reporterBond math.Int) (math.Int, error)

func (Keeper) SetBlockInfo

func (k Keeper) SetBlockInfo(ctx context.Context, hashId []byte) error

creates a snapshot of total reporter power and total tips

func (Keeper) SetNewDispute

func (k Keeper) SetNewDispute(ctx sdk.Context, sender sdk.AccAddress, msg types.MsgProposeDispute) error

Set new dispute

func (Keeper) SetStartVote

func (k Keeper) SetStartVote(ctx sdk.Context, id uint64) error

Set vote start info for a dispute

func (Keeper) SetTeamVote

func (k Keeper) SetTeamVote(ctx context.Context, id uint64, voter sdk.AccAddress, choice types.VoteEnum) (math.Int, error)

func (Keeper) SetTokenholderVote

func (k Keeper) SetTokenholderVote(ctx context.Context, id uint64, voter sdk.AccAddress, blockNumber uint64, choice types.VoteEnum) (math.Int, error)

func (Keeper) SetVoterReporterStake

func (k Keeper) SetVoterReporterStake(ctx context.Context, id uint64, voter sdk.AccAddress, blockNumber uint64, choice types.VoteEnum) (math.Int, error)

func (Keeper) SetVoterTips

func (k Keeper) SetVoterTips(ctx context.Context, id uint64, voter sdk.AccAddress, blockNumber uint64, choice types.VoteEnum) (math.Int, error)

func (Keeper) SlashAndJailReporter

func (k Keeper) SlashAndJailReporter(ctx sdk.Context, report oracletypes.MicroReport, category types.DisputeCategory, hashId []byte) error

Slash and jail reporter

func (Keeper) SubtractReporterVoteCount

func (k Keeper) SubtractReporterVoteCount(ctx context.Context, id, amount uint64, choice types.VoteEnum) error

func (Keeper) TallyVote

func (k Keeper) TallyVote(ctx context.Context, id uint64) error

TallyVote determines whether the dispute vote has either reached quorum or the vote period has ended. If so, it calculates the given dispute round's outcome.

func (Keeper) TeamVote

func (k Keeper) TeamVote(ctx context.Context, id uint64) (math.Int, error)

func (Keeper) UpdateDispute

func (k Keeper) UpdateDispute(
	ctx context.Context,
	id uint64,
	dispute types.Dispute,
	vote types.Vote,
	scaledSupport, scaledAgainst, scaledInvalid math.Int, quorum bool,
) error

type Querier

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) Disputes

func (Querier) Params

func (Querier) TeamVote

type VoterInfo

type VoterInfo struct {
	Voter sdk.AccAddress
	Power math.Int
	Share math.Int
}

type VotersVoteIndex

type VotersVoteIndex struct {
	VotersById *indexes.Multi[uint64, collections.Pair[uint64, []byte], types.Voter]
}

func (VotersVoteIndex) IndexesList

Jump to

Keyboard shortcuts

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