keeper

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryParameters      = "params"
	QueryBeacon          = "beacon"
	QueryBeacons         = "beacons"
	QueryBeaconTimestamp = "timestamp"
)

query endpoints supported by the beacon Querier

View Source
const (
	TestDenomination = "testc"
)

Variables

View Source
var (
	TestAddrs = []sdk.AccAddress{
		bAddr1, bAddr2, bAddr3, bAddr4, bAddr5,
	}
)

dummy addresses used for testing

Functions

func BeaconEqual

func BeaconEqual(wcA types.Beacon, wcB types.Beacon) bool

BeaconEqual checks if two Beacons are equal

func BeaconTimestampEqual

func BeaconTimestampEqual(lA, lB types.BeaconTimestamp) bool

BeaconTimestampEqual checks if two BeaconTimestamps are equal

func GenerateRandomAddresses

func GenerateRandomAddresses(num int) []sdk.AccAddress

func GenerateRandomString

func GenerateRandomString(length int) string

GenerateRandomString generates a random string given a length, based on a set character set

func GenerateRandomStringWithCharset

func GenerateRandomStringWithCharset(length int, charset string) string

GenerateRandomStringWithCharset generates a random string given a length and character set

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier is the module level router for state queries

func ParamsEqual

func ParamsEqual(paramsA, paramsB types.Params) bool

ParamsEqual checks params are equal

func RandInBetween

func RandInBetween(min, max int) int

RandInBetween generates a random number between two given values

Types

type Keeper

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

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

func NewKeeper

func NewKeeper(storeKey sdk.StoreKey, paramSpace params.Subspace, cdc *codec.Codec) Keeper

NewKeeper creates new instances of the beacon Keeper

func (Keeper) Cdc

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

func (Keeper) GetAllBeaconTimestamps

func (k Keeper) GetAllBeaconTimestamps(ctx sdk.Context, beaconID uint64) (timestamps types.BeaconTimestamps)

GetAllBeaconTimestamps Get an iterator over all a Beacon's timestamps in which the keys are the beaconID and the values are the BeaconTimestamps

func (Keeper) GetAllBeacons

func (k Keeper) GetAllBeacons(ctx sdk.Context) (beacons types.Beacons)

GetAllBeacons returns all the registered BEACON metadata from store

func (Keeper) GetBeacon

func (k Keeper) GetBeacon(ctx sdk.Context, beaconID uint64) types.Beacon

GetBeacon Gets the entire BEACON metadata struct for a beaconID

func (Keeper) GetBeaconOwner

func (k Keeper) GetBeaconOwner(ctx sdk.Context, beaconID uint64) sdk.AccAddress

GetBeaconOwner - get the current owner of a BEACON

func (Keeper) GetBeaconTimestampByID

func (k Keeper) GetBeaconTimestampByID(ctx sdk.Context, beaconID uint64, timestampID uint64) types.BeaconTimestamp

GetBeaconTimestampByID Gets the beacon timestamp data for a beaconID and timestampID

func (Keeper) GetBeaconTimestampsFiltered

func (k Keeper) GetBeaconTimestampsFiltered(ctx sdk.Context, params types.QueryBeaconTimestampParams) []types.BeaconTimestamp

GetBeaconTimestampsFiltered retrieves a BEACON's timestamps filtered by submit time, or the hash itself

func (Keeper) GetBeaconsFiltered

func (k Keeper) GetBeaconsFiltered(ctx sdk.Context, params types.QueryBeaconParams) []types.Beacon

GetBeaconsFiltered retrieves BEACONs filtered by a given set of params which include pagination parameters along a moniker and owner address.

NOTE: If no filters are provided, all proposals will be returned in paginated form.

func (Keeper) GetBeaconsIterator

func (k Keeper) GetBeaconsIterator(ctx sdk.Context) sdk.Iterator

GetBeaconsIterator Get an iterator over all BEACONs in which the keys are the BEACON Ids and the values are the BEACONs

func (Keeper) GetHighestBeaconID

func (k Keeper) GetHighestBeaconID(ctx sdk.Context) (beaconID uint64, err error)

GetHighestBeaconID gets the highest BEACON ID

func (Keeper) GetParamDenom

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

func (Keeper) GetParamRecordFee

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

func (Keeper) GetParamRegistrationFee

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

func (Keeper) GetParams

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

GetParams returns the total set of Beacon parameters.

func (Keeper) GetRecordFeeAsCoin

func (k Keeper) GetRecordFeeAsCoin(ctx sdk.Context) sdk.Coin

func (Keeper) GetRecordFeeAsCoins

func (k Keeper) GetRecordFeeAsCoins(ctx sdk.Context) sdk.Coins

func (Keeper) GetRegistrationFeeAsCoin

func (k Keeper) GetRegistrationFeeAsCoin(ctx sdk.Context) sdk.Coin

func (Keeper) GetRegistrationFeeAsCoins

func (k Keeper) GetRegistrationFeeAsCoins(ctx sdk.Context) sdk.Coins

func (Keeper) GetZeroFeeAsCoin

func (k Keeper) GetZeroFeeAsCoin(ctx sdk.Context) sdk.Coin

func (Keeper) GetZeroFeeAsCoins

func (k Keeper) GetZeroFeeAsCoins(ctx sdk.Context) sdk.Coins

func (Keeper) IsAuthorisedToRecord

func (k Keeper) IsAuthorisedToRecord(ctx sdk.Context, beaconID uint64, recorder sdk.AccAddress) bool

IsAuthorisedToRecord ensures only the BEACON owner is recording hashes

func (Keeper) IsBeaconRegistered

func (k Keeper) IsBeaconRegistered(ctx sdk.Context, beaconID uint64) bool

IsBeaconRegistered Checks if the BEACON is present in the store or not

func (Keeper) IsBeaconTimestampRecordedByHashTime

func (k Keeper) IsBeaconTimestampRecordedByHashTime(ctx sdk.Context, beaconID uint64, hash string, subTime uint64) bool

func (Keeper) IsBeaconTimestampRecordedByID

func (k Keeper) IsBeaconTimestampRecordedByID(ctx sdk.Context, beaconID uint64, timestampID uint64) bool

IsBeaconTimestampRecordedByID Check if the BEACON timestamp is present in the store or not, given the beaconID and timestampID

func (Keeper) IterateBeaconTimestamps

func (k Keeper) IterateBeaconTimestamps(ctx sdk.Context, beaconID uint64, cb func(beaconTimestamp types.BeaconTimestamp) (stop bool))

IterateBeacons iterates over the all the BEACON's timestamps and performs a callback function

func (Keeper) IterateBeacons

func (k Keeper) IterateBeacons(ctx sdk.Context, cb func(beacon types.Beacon) (stop bool))

IterateBeacons iterates over the all the BEACON metadata and performs a callback function

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) RecordBeaconTimestamp

func (k Keeper) RecordBeaconTimestamp(
	ctx sdk.Context,
	beaconID uint64,
	hash string,
	submitTime uint64,
	owner sdk.AccAddress) (uint64, error)

RecordBeaconTimestamp records a BEACON timestamp hash for a registered BEACON

func (Keeper) RegisterBeacon

func (k Keeper) RegisterBeacon(ctx sdk.Context, moniker string, beaconName string, owner sdk.AccAddress) (uint64, error)

RegisterBeacon registers a BEACON in the store

func (Keeper) SetBeacon

func (k Keeper) SetBeacon(ctx sdk.Context, beacon types.Beacon) error

SetBeacon Sets the BEACON metadata struct for a beaconID

func (Keeper) SetBeaconTimestamp

func (k Keeper) SetBeaconTimestamp(ctx sdk.Context, beaconTimestamp types.BeaconTimestamp) error

SetBeaconTimestamp Sets the Beacon timestamp struct for a beaconID + timestampID

func (Keeper) SetHighestBeaconID

func (k Keeper) SetHighestBeaconID(ctx sdk.Context, beaconID uint64)

SetHighestBeaconID sets the new highest BEACON ID to the store

func (Keeper) SetLastTimestampID

func (k Keeper) SetLastTimestampID(ctx sdk.Context, beaconID uint64, timestampID uint64) error

SetLastTimestampID - sets the last timestamp ID submitted

func (Keeper) SetParams

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

SetParams sets the total set of Beacon parameters.

type NodeQuerier

type NodeQuerier interface {
	// QueryWithData performs a query to a Tendermint node with the provided path
	// and a data payload. It returns the result and subTime of the query upon success
	// or an error if the query fails.
	QueryWithData(path string, data []byte) ([]byte, int64, error)
}

NodeQuerier is an interface that is satisfied by types that provide the QueryWithData method

type ParamsRetriever

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

ParamsRetriever defines the properties of a type that can be used to retrieve enterprise params.

func NewParamsRetriever

func NewParamsRetriever(querier NodeQuerier) ParamsRetriever

NewParamsRetriever initialises a new ParamsRetriever instance.

func (ParamsRetriever) GetParams

func (ar ParamsRetriever) GetParams() (types.Params, error)

GetParams queries for parameters. An error is returned if the query or decoding fails.

func (ParamsRetriever) GetParamsHeight

func (ar ParamsRetriever) GetParamsHeight() (types.Params, int64, error)

GetParamsHeight queries for parameters. Returns the subTime of the query with the params. An error is returned if the query or decoding fails.

Jump to

Keyboard shortcuts

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