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: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TRBBridgeQueryType = "TRBBridge"
)

Variables

This section is empty.

Functions

func CalculateRewardAmount

func CalculateRewardAmount(reporterPower, reportsCount, totalPower uint64, reward math.Int) reportertypes.BigUint

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func WithCollectionPaginationTriplePrefix

func WithCollectionPaginationTriplePrefix[K1, K2, K3 any](prefix K1) func(o *query.CollectionsPaginateOptions[collections.Triple[K1, K2, K3]])

WithCollectionPaginationTriplePrefix applies a prefix to a collection, whose key is a collection.Triple, being paginated that needs prefixing.

func WithCollectionPaginationTripleSuperPrefix

func WithCollectionPaginationTripleSuperPrefix[K1, K2, K3 any](prefix1 K1, prefix2 K2) func(o *query.CollectionsPaginateOptions[collections.Triple[K1, K2, K3]])

Types

type Hooks

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

Hooks wrapper struct for oracle keeper

func (Hooks) AfterDataSpecUpdated

func (h Hooks) AfterDataSpecUpdated(ctx context.Context, querytype string, dataspec rtypes.DataSpec) error

type Keeper

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

	Schema      collections.Schema                                                                          // key: reporter, queryid
	Tips        *collections.IndexedMap[collections.Pair[[]byte, []byte], math.Int, types.TipsIndex]        // key: queryId, tipper
	TipperTotal *collections.IndexedMap[collections.Pair[[]byte, uint64], math.Int, types.TipperTotalIndex] // key: tipperAcc, blockNumber
	// total tips given over time
	TotalTips          collections.Map[uint64, math.Int]                                                                          // key: blockNumber, value: total tips                                  // key: queryId, timestamp
	Nonces             collections.Map[[]byte, uint64]                                                                            // key: queryId
	Reports            *collections.IndexedMap[collections.Triple[[]byte, []byte, uint64], types.MicroReport, types.ReportsIndex] // key: queryId, reporter, query.id
	QuerySequencer     collections.Sequence
	Query              *collections.IndexedMap[collections.Pair[[]byte, uint64], types.QueryMeta, types.QueryMetaIndex]  // key: queryId
	Aggregates         *collections.IndexedMap[collections.Pair[[]byte, uint64], types.Aggregate, types.AggregatesIndex] // key: queryId, timestamp                                                                    // key: queryId                                                                  // keep track of the current cycle
	Cyclelist          collections.Map[[]byte, []byte]
	CyclelistSequencer collections.Sequence
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	accountKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	registryKeeper types.RegistryKeeper,
	reporterKeeper types.ReporterKeeper,
	authority string,
) Keeper

func (Keeper) AddToTipperTotal

func (k Keeper) AddToTipperTotal(ctx context.Context, tipper sdk.AccAddress, amt math.Int) error

func (Keeper) AddtoTotalTips

func (k Keeper) AddtoTotalTips(ctx context.Context, amt math.Int) error

func (Keeper) AllocateRewards

func (k Keeper) AllocateRewards(ctx context.Context, reporters []*types.AggregateReporter, reward math.Int, fromPool string) error

AllocateRewards distributes rewards to reporters based on their power and number of reports. It calculates the reward amount for each reporter and allocates the rewards. Finally, it sends the allocated rewards to the apprppopriate module based on the source of the reward.

func (Keeper) AllocateTip

func (k Keeper) AllocateTip(ctx context.Context, addr []byte, amount reportertypes.BigUint, height uint64) error

func (Keeper) ClearOldqueries

func (k Keeper) ClearOldqueries(ctx context.Context, queryId []byte) error

func (Keeper) CurrentQuery

func (k Keeper) CurrentQuery(ctx context.Context, queryId []byte) (query types.QueryMeta, err error)

func (Keeper) DirectReveal

func (k Keeper) DirectReveal(ctx context.Context,
	query types.QueryMeta,
	qDataBytes []byte,
	value string,
	reporterAddr sdk.AccAddress,
	votingPower uint64,
	bridgeDeposit bool,
) error

func (Keeper) FlagAggregateReport

func (k Keeper) FlagAggregateReport(ctx context.Context, report types.MicroReport) error

func (Keeper) GenesisCycleList

func (k Keeper) GenesisCycleList(ctx context.Context, cyclelist [][]byte) error

func (Keeper) GetAggregateBefore

func (k Keeper) GetAggregateBefore(ctx context.Context, queryId []byte, timestampBefore time.Time) (aggregate *types.Aggregate, timestamp time.Time, err error)

func (Keeper) GetAggregateBeforeByReporter

func (k Keeper) GetAggregateBeforeByReporter(ctx context.Context, queryId []byte, timestamp time.Time, reporter sdk.AccAddress) (aggregate *types.Aggregate, err error)

func (Keeper) GetAggregateByIndex

func (k Keeper) GetAggregateByIndex(ctx context.Context, queryId []byte, index uint64) (aggregate *types.Aggregate, timestamp time.Time, err error)

func (Keeper) GetAggregateByTimestamp

func (k Keeper) GetAggregateByTimestamp(ctx context.Context, queryId []byte, timestamp time.Time) (aggregate types.Aggregate, err error)

func (Keeper) GetAggregatedReportsByHeight

func (k Keeper) GetAggregatedReportsByHeight(ctx context.Context, height uint64) []types.Aggregate

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the module's authority.

func (Keeper) GetCurrentAggregateReport

func (k Keeper) GetCurrentAggregateReport(ctx context.Context, queryId []byte) (aggregate *types.Aggregate, timestamp time.Time, err error)

func (Keeper) GetCurrentQueryInCycleList

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

func (Keeper) GetCyclelist

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

func (Keeper) GetDataSpec

func (k Keeper) GetDataSpec(ctx context.Context, queryType string) (regTypes.DataSpec, error)

func (Keeper) GetNextCurrentQueryInCycleList

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

func (Keeper) GetParams

func (k Keeper) GetParams(ctx context.Context) (types.Params, error)

GetParams sets the x/oracle module parameters.

func (Keeper) GetQueryTip

func (k Keeper) GetQueryTip(ctx context.Context, queryId []byte) (math.Int, error)

func (Keeper) GetTimeBasedRewards

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

func (Keeper) GetTimeBasedRewardsAccount

func (k Keeper) GetTimeBasedRewardsAccount(ctx context.Context) sdk.ModuleAccountI

func (Keeper) GetTimestampAfter

func (k Keeper) GetTimestampAfter(ctx context.Context, queryId []byte, timestamp time.Time) (time.Time, error)

func (Keeper) GetTimestampBefore

func (k Keeper) GetTimestampBefore(ctx context.Context, queryId []byte, timestamp time.Time) (time.Time, error)

func (Keeper) GetTipsAtBlockForTipper

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

get tips at block

func (Keeper) GetTotalTips

func (k Keeper) GetTotalTips(ctx context.Context) (math.Int, error)

func (Keeper) GetTotalTipsAtBlock

func (k Keeper) GetTotalTipsAtBlock(ctx context.Context, blockNumber uint64) (math.Int, error)

func (Keeper) GetUserTips

func (k Keeper) GetUserTips(ctx context.Context, tipper sdk.AccAddress) (math.Int, error)

func (Keeper) HandleBridgeDepositDirectReveal

func (k Keeper) HandleBridgeDepositDirectReveal(
	ctx context.Context,
	query types.QueryMeta,
	querydata []byte,
	reporterAcc sdk.AccAddress,
	value string,
	voterPower uint64,
) error

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Return the oracle hooks

func (Keeper) InitCycleListQuery

func (k Keeper) InitCycleListQuery(ctx context.Context, queries [][]byte) error

should be called only once when updating the cycle list

func (Keeper) InitializeQuery

func (k Keeper) InitializeQuery(ctx context.Context, querydata []byte) (types.QueryMeta, error)

initialize query for a given query data

func (Keeper) Logger

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

func (Keeper) PreventBridgeWithdrawalReport

func (k Keeper) PreventBridgeWithdrawalReport(queryData []byte) error

func (Keeper) RotateQueries

func (k Keeper) RotateQueries(ctx context.Context) error

rotation of the cycle list

func (Keeper) SetAggregate

func (k Keeper) SetAggregate(ctx context.Context, report *types.Aggregate) error

func (Keeper) SetAggregatedReport

func (k Keeper) SetAggregatedReport(ctx context.Context) (err error)

SetAggregatedReport calculates and allocates rewards to reporters based on aggregated reports. at a specific blockchain height (to be ran in end-blocker) It retrieves the revealed reports from the reports store, by query. calculates the aggregate report for each query using either the weighted-median or weighted-mode method. Rewards based on the source are then allocated to the reporters.

func (Keeper) SetParams

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

SetParams sets the x/oracle module parameters.

func (Keeper) SetValue

func (k Keeper) SetValue(ctx context.Context, reporter sdk.AccAddress, query types.QueryMeta, val string, queryData []byte, power uint64, incycle bool) error

func (Keeper) TokenBridgeDepositCheck

func (k Keeper) TokenBridgeDepositCheck(ctx context.Context, queryData []byte) (types.QueryMeta, error)

func (Keeper) UpdateQuery

func (k Keeper) UpdateQuery(ctx context.Context, queryType string, newBlockWindow uint64) error

func (Keeper) WeightedMedian

func (k Keeper) WeightedMedian(ctx context.Context, reports []types.MicroReport, metaId uint64) (*types.Aggregate, error)

func (Keeper) WeightedMode

func (k Keeper) WeightedMode(ctx context.Context, reports []types.MicroReport, metaId uint64) (*types.Aggregate, error)

type Querier

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

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) GetQuery

func (Querier) Params

type ReportersReportCount

type ReportersReportCount struct {
	Power   uint64
	Reports uint64
	Height  uint64
}

Jump to

Keyboard shortcuts

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