func (k Keeper) GetOracleRandRequest(ctx sdk.Context, requestContextID []byte) (types.Request, error) {
	store := ctx.KVStore(k.storeKey)
	bz := store.Get(types.KeyOracleRandomRequest(requestContextID))
	if bz == nil {
		return types.Request{}, sdkerrors.Wrap(types.ErrInvalidRequestContextID, hex.EncodeToString(requestContextID))
	}
	var request types.Request
	k.cdc.MustUnmarshal(bz, &request)
	return request, nil
}
GetOracleRandRequest retrieves the oracle random number request by the specified request id
package keeper
import (
	"encoding/hex"
	"github.com/tendermint/tendermint/libs/log"
	"github.com/cosmos/cosmos-sdk/codec"
	sdk "github.com/cosmos/cosmos-sdk/types"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	"github.com/irisnet/irismod/modules/random/types"
)
type Keeper struct {
	cdc           codec.Codec
	storeKey      sdk.StoreKey
	bankKeeper    types.BankKeeper
	serviceKeeper types.ServiceKeeper
}
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, bankKeeper types.BankKeeper, serviceKeeper types.ServiceKeeper) Keeper {
	keeper := Keeper{
		cdc:           cdc,
		storeKey:      key,
		bankKeeper:    bankKeeper,
		serviceKeeper: serviceKeeper,
	}
	_ = serviceKeeper.RegisterResponseCallback(types.ModuleName, keeper.HandlerResponse)
	_ = serviceKeeper.RegisterStateCallback(types.ModuleName, keeper.HandlerStateChanged)
	return keeper
}
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
	return ctx.Logger().With("module", types.ModuleName)
}
func (k Keeper) GetCdc() codec.BinaryCodec {
	return k.cdc
}
func (k Keeper) RequestRandom(
	ctx sdk.Context, consumer sdk.AccAddress,
	blockInterval uint64, oracle bool,
	serviceFeeCap sdk.Coins,
) (types.Request, error) {
	currentHeight := ctx.BlockHeight()
	destHeight := currentHeight + int64(blockInterval)
	txHash := types.SHA256(ctx.TxBytes())
	var request types.Request
	if oracle {
		requestContextID, err := k.RequestService(ctx, consumer, serviceFeeCap)
		if err != nil {
			return request, err
		}
		request = types.NewRequest(currentHeight, consumer.String(), hex.EncodeToString(txHash), oracle, serviceFeeCap, requestContextID.String())
	} else {
		request = types.NewRequest(currentHeight, consumer.String(), hex.EncodeToString(txHash), oracle, nil, "")
	}
	reqID := types.GenerateRequestID(request)
	k.EnqueueRandomRequest(ctx, destHeight, reqID, request)
	return request, nil
}
func (k Keeper) SetRandom(ctx sdk.Context, reqID []byte, random types.Random) {
	store := ctx.KVStore(k.storeKey)
	bz := k.cdc.MustMarshal(&random)
	store.Set(types.KeyRandom(reqID), bz)
}
func (k Keeper) EnqueueRandomRequest(ctx sdk.Context, height int64, reqID []byte, request types.Request) {
	store := ctx.KVStore(k.storeKey)
	bz := k.cdc.MustMarshal(&request)
	store.Set(types.KeyRandomRequestQueue(height, reqID), bz)
}
func (k Keeper) DequeueRandomRequest(ctx sdk.Context, height int64, reqID []byte) {
	store := ctx.KVStore(k.storeKey)
	store.Delete(types.KeyRandomRequestQueue(height, reqID))
}
func (k Keeper) SetOracleRandRequest(ctx sdk.Context, requestContextID []byte, request types.Request) {
	store := ctx.KVStore(k.storeKey)
	bz := k.cdc.MustMarshal(&request)
	store.Set(types.KeyOracleRandomRequest(requestContextID), bz)
}