Documentation ¶
Index ¶
- Constants
- Variables
- func GetSessionEndBlockHeight(blockHeight int64) int64
- func GetSessionGracePeriodBlockCount() int64
- func GetSessionId(appPubKey, serviceId string, blockHashBz []byte, blockHeight int64) (sessionId string, sessionIdBz []byte)
- func GetSessionNumber(blockHeight int64) int64
- func GetSessionStartBlockHeight(blockHeight int64) int64
- func NewMsgServerImpl(keeper Keeper) types.MsgServer
- func NewSessionHydrator(appAddress string, serviceId string, blockHeight int64) *sessionHydrator
- type Keeper
- func (k Keeper) GetAuthority() string
- func (k Keeper) GetBlockHash(ctx context.Context, height int64) []byte
- func (k Keeper) GetParams(ctx context.Context) (params types.Params)
- func (k Keeper) GetSession(ctx context.Context, req *types.QueryGetSessionRequest) (*types.QueryGetSessionResponse, error)
- func (k Keeper) HydrateSession(ctx context.Context, sh *sessionHydrator) (*types.Session, error)
- func (k Keeper) Logger() log.Logger
- func (k Keeper) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) SetParams(ctx context.Context, params types.Params) error
- func (k Keeper) StoreBlockHash(goCtx context.Context)
Constants ¶
const ( // TODO_BLOCKER: Remove direct usage of these constants in helper functions // when they will be replaced by governance params NumBlocksPerSession = 4 // Duration of the grace period in number of sessions SessionGracePeriod = 1 NumSupplierPerSession = 15 SessionIDComponentDelimiter = "." )
TODO_BLOCKER(#21): Make these configurable governance param
Variables ¶
var SHA3HashLen = crypto.SHA3_256.Size()
Functions ¶
func GetSessionEndBlockHeight ¶
GetSessionEndBlockHeight returns the block height at which the session ends Returns 0 if the block height is not a consensus produced block. Example: If NumBlocksPerSession == 4, sessions end at blocks 4, 8, 11, etc.
func GetSessionGracePeriodBlockCount ¶
func GetSessionGracePeriodBlockCount() int64
GetSessionGracePeriodBlockCount returns the number of blocks in the session grace period.
func GetSessionId ¶
func GetSessionId( appPubKey, serviceId string, blockHashBz []byte, blockHeight int64, ) (sessionId string, sessionIdBz []byte)
GetSessionId returns the string and bytes representation of the sessionId given the application public key, service ID, block hash, and block height that is used to get the session start block height.
func GetSessionNumber ¶
GetSessionNumber returns the session number given the block height. Returns session number 0 if the block height is not a consensus produced block. Returns session number 1 for block 1 to block NumBlocksPerSession - 1 (inclusive). i.e. If NubBlocksPerSession == 4, session == 1 for [1, 4], session == 2 for [5, 8], etc.
func GetSessionStartBlockHeight ¶
GetSessionStartBlockHeight returns the block height at which the session starts Returns 0 if the block height is not a consensus produced block. Example: If NumBlocksPerSession == 4, sessions start at blocks 1, 5, 9, etc.
func NewMsgServerImpl ¶
NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.
func NewSessionHydrator ¶
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeService store.KVStoreService, logger log.Logger, authority string, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, applicationKeeper types.ApplicationKeeper, supplierKeeper types.SupplierKeeper, ) Keeper
func (Keeper) GetAuthority ¶
GetAuthority returns the module's authority.
func (Keeper) GetBlockHash ¶
GetBlockHash returns the hash of the block at the given height.
func (Keeper) GetSession ¶
func (k Keeper) GetSession(ctx context.Context, req *types.QueryGetSessionRequest) (*types.QueryGetSessionResponse, error)
GetSession should be deterministic and always return the same session for the same block height.
func (Keeper) HydrateSession ¶
GetSession implements of the exposed `UtilityModule.GetSession` function TECHDEBT(#519,#348): Add custom error types depending on the type of issue that occurred and assert on them in the unit tests.
func (Keeper) Params ¶
func (k Keeper) Params( ctx context.Context, req *types.QueryParamsRequest, ) (*types.QueryParamsResponse, error)
func (Keeper) StoreBlockHash ¶
StoreBlockHash is called at the end of every block. It fetches the block hash from the committed block ans saves its hash in the store.