types

package
v0.0.0-...-baf6593 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	FundingSampleEpochInfoName EpochInfoName = "funding-sample"
	FundingTickEpochInfoName   EpochInfoName = "funding-tick"
	StatsEpochInfoName         EpochInfoName = "stats-epoch"

	FundingTickEpochDuration   uint32 = 3600
	FundingSampleEpochDuration uint32 = 60
	StatsEpochDuration         uint32 = 3600
)
View Source
const (
	EventTypeNewEpoch = "new_epoch"

	AttributeKeyEpochInfoName       = "epoch_info_name"
	AttributeKeyEpochNumber         = "epoch_number"
	AttributeKeyEpochStartTickTime  = "epoch_start_tick_time"
	AttributeKeyEpochStartBlockTime = "epoch_start_block_time"
	AttributeKeyEpochStartBlock     = "epoch_start_block"
)
View Source
const (
	// ModuleName defines the module name
	ModuleName = "epochs"

	// StoreKey defines the primary module store key
	StoreKey = ModuleName
)

Module name and store keys

View Source
const (
	// EpochInfoKeyPrefix is the prefix to retrieve all EpochInfo
	EpochInfoKeyPrefix = "Info:"
)

State

Variables

View Source
var (
	ErrInvalidLengthEpochInfo        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowEpochInfo          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupEpochInfo = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrEmptyEpochInfoName = errorsmod.Register(
		ModuleName,
		2,
		"EpochInfo name is empty",
	)
	ErrDurationIsZero = errorsmod.Register(
		ModuleName,
		3,
		"Duration is zero",
	)
	ErrEpochInfoAlreadyExists = errorsmod.Register(
		ModuleName,
		4,
		"EpochInfo name already exists",
	)
	ErrEpochInfoNotFound = errorsmod.Register(
		ModuleName,
		5,
		"EpochInfo name not found",
	)
	ErrInvalidCurrentEpochAndCurrentEpochStartBlockTuple = errorsmod.Register(
		ModuleName,
		6,
		"Invalid CurrentEpoch and CurrentEpochStartBlock tuple: CurrentEpoch should"+
			" be zero if and only if CurrentEpochStartBlock is zero",
	)
)

x/epochs module sentinel errors

View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthQuery        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuery          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
)
View Source
var GenesisEpochs = []EpochInfo{

	{
		Name:                   string(FundingTickEpochInfoName),
		Duration:               FundingTickEpochDuration,
		NextTick:               0,
		CurrentEpoch:           0,
		CurrentEpochStartBlock: 0,
		FastForwardNextTick:    true,
	},

	{
		Name:                   string(FundingSampleEpochInfoName),
		Duration:               FundingSampleEpochDuration,
		NextTick:               30,
		CurrentEpoch:           0,
		CurrentEpochStartBlock: 0,
		FastForwardNextTick:    true,
	},
	{
		Name:                   string(StatsEpochInfoName),
		Duration:               StatsEpochDuration,
		NextTick:               0,
		CurrentEpoch:           0,
		CurrentEpochStartBlock: 0,
		FastForwardNextTick:    true,
	},
}

Functions

func NewEpochEvent

func NewEpochEvent(ctx sdk.Context, epoch EpochInfo, currentTick uint32) sdk.Event

NewEpochEvent constructs a new_epoch sdk.Event.

func RegisterCodec

func RegisterCodec(cdc *codec.LegacyAmino)

func RegisterInterfaces

func RegisterInterfaces(registry cdctypes.InterfaceRegistry)

func RegisterQueryHandler

func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterQueryHandler registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterQueryHandlerClient

func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error

RegisterQueryHandlerClient registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "QueryClient" to call the correct interceptors.

func RegisterQueryHandlerFromEndpoint

func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterQueryHandlerServer

func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error

RegisterQueryHandlerServer registers the http handlers for service Query to "mux". UnaryRPC :call QueryServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

Types

type EpochInfo

type EpochInfo struct {
	// name is the unique identifier.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// next_tick indicates when the next epoch starts (in Unix Epoch seconds),
	// if `EpochInfo` has been initialized.
	// If `EpochInfo` is not initialized yet, `next_tick` indicates the earliest
	// initialization time (see `is_initialized` below).
	NextTick uint32 `protobuf:"varint,2,opt,name=next_tick,json=nextTick,proto3" json:"next_tick,omitempty"`
	// duration of the epoch in seconds.
	Duration uint32 `protobuf:"varint,3,opt,name=duration,proto3" json:"duration,omitempty"`
	// current epoch is the number of the current epoch.
	// 0 if `next_tick` has never been reached, positive otherwise.
	CurrentEpoch uint32 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
	// current_epoch_start_block indicates the block height when the current
	// epoch started. 0 if `current_epoch` is 0.
	CurrentEpochStartBlock uint32 `` /* 132-byte string literal not displayed */
	// is_initialized indicates whether the `EpochInfo` has been initialized
	// and started ticking.
	// An `EpochInfo` is initialized when all below conditions are true:
	// - Not yet initialized
	// - `BlockHeight` >= 2
	// - `BlockTime` >= `next_tick`
	IsInitialized bool `protobuf:"varint,6,opt,name=is_initialized,json=isInitialized,proto3" json:"is_initialized,omitempty"`
	// fast_forward_next_tick specifies whether during initialization, `next_tick`
	// should be fast-forwarded to be greater than the current block time.
	// If `false`, the original `next_tick` value is
	// unchanged during initialization.
	// If `true`, `next_tick` will be set to the smallest value `x` greater than
	// the current block time such that `(x - next_tick) % duration = 0`.
	FastForwardNextTick bool `protobuf:"varint,7,opt,name=fast_forward_next_tick,json=fastForwardNextTick,proto3" json:"fast_forward_next_tick,omitempty"`
}

EpochInfo stores metadata of an epoch timer.

func (*EpochInfo) Descriptor

func (*EpochInfo) Descriptor() ([]byte, []int)

func (*EpochInfo) GetCurrentEpoch

func (m *EpochInfo) GetCurrentEpoch() uint32

func (*EpochInfo) GetCurrentEpochStartBlock

func (m *EpochInfo) GetCurrentEpochStartBlock() uint32

func (*EpochInfo) GetDuration

func (m *EpochInfo) GetDuration() uint32

func (EpochInfo) GetEpochInfoName

func (epoch EpochInfo) GetEpochInfoName() EpochInfoName

GetEpochInfoName returns Id from epoch info.

func (*EpochInfo) GetFastForwardNextTick

func (m *EpochInfo) GetFastForwardNextTick() bool

func (*EpochInfo) GetIsInitialized

func (m *EpochInfo) GetIsInitialized() bool

func (*EpochInfo) GetName

func (m *EpochInfo) GetName() string

func (*EpochInfo) GetNextTick

func (m *EpochInfo) GetNextTick() uint32

func (*EpochInfo) Marshal

func (m *EpochInfo) Marshal() (dAtA []byte, err error)

func (*EpochInfo) MarshalTo

func (m *EpochInfo) MarshalTo(dAtA []byte) (int, error)

func (*EpochInfo) MarshalToSizedBuffer

func (m *EpochInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*EpochInfo) ProtoMessage

func (*EpochInfo) ProtoMessage()

func (*EpochInfo) Reset

func (m *EpochInfo) Reset()

func (*EpochInfo) Size

func (m *EpochInfo) Size() (n int)

func (*EpochInfo) String

func (m *EpochInfo) String() string

func (*EpochInfo) Unmarshal

func (m *EpochInfo) Unmarshal(dAtA []byte) error

func (EpochInfo) Validate

func (epoch EpochInfo) Validate() error

Validate does basic validation for epoch info.

func (*EpochInfo) XXX_DiscardUnknown

func (m *EpochInfo) XXX_DiscardUnknown()

func (*EpochInfo) XXX_Marshal

func (m *EpochInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EpochInfo) XXX_Merge

func (m *EpochInfo) XXX_Merge(src proto.Message)

func (*EpochInfo) XXX_Size

func (m *EpochInfo) XXX_Size() int

func (*EpochInfo) XXX_Unmarshal

func (m *EpochInfo) XXX_Unmarshal(b []byte) error

type EpochInfoName

type EpochInfoName string

type GenesisState

type GenesisState struct {
	EpochInfoList []EpochInfo `protobuf:"bytes,1,rep,name=epoch_info_list,json=epochInfoList,proto3" json:"epoch_info_list"`
}

GenesisState defines the epochs module's genesis state.

func DefaultGenesis

func DefaultGenesis() *GenesisState

DefaultGenesis returns the default epochs genesis state.

func DefaultGenesisWithEpochs

func DefaultGenesisWithEpochs(epochs ...EpochInfo) *GenesisState

DefaultGenesisWithEpochs returns the default genesis state with input epochs added or overwritten.

func (*GenesisState) Descriptor

func (*GenesisState) Descriptor() ([]byte, []int)

func (*GenesisState) GetEpochInfoList

func (m *GenesisState) GetEpochInfoList() []EpochInfo

func (*GenesisState) Marshal

func (m *GenesisState) Marshal() (dAtA []byte, err error)

func (*GenesisState) MarshalTo

func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)

func (*GenesisState) MarshalToSizedBuffer

func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GenesisState) ProtoMessage

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset

func (m *GenesisState) Reset()

func (*GenesisState) Size

func (m *GenesisState) Size() (n int)

func (*GenesisState) String

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal

func (m *GenesisState) Unmarshal(dAtA []byte) error

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic genesis state validation returning an error upon any failure.

func (*GenesisState) XXX_DiscardUnknown

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal

func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenesisState) XXX_Merge

func (m *GenesisState) XXX_Merge(src proto.Message)

func (*GenesisState) XXX_Size

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal

func (m *GenesisState) XXX_Unmarshal(b []byte) error

type QueryAllEpochInfoRequest

type QueryAllEpochInfoRequest struct {
	Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryAllEpochInfoRequest is request type for the AllEpochInfo RPC method.

func (*QueryAllEpochInfoRequest) Descriptor

func (*QueryAllEpochInfoRequest) Descriptor() ([]byte, []int)

func (*QueryAllEpochInfoRequest) GetPagination

func (m *QueryAllEpochInfoRequest) GetPagination() *query.PageRequest

func (*QueryAllEpochInfoRequest) Marshal

func (m *QueryAllEpochInfoRequest) Marshal() (dAtA []byte, err error)

func (*QueryAllEpochInfoRequest) MarshalTo

func (m *QueryAllEpochInfoRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllEpochInfoRequest) MarshalToSizedBuffer

func (m *QueryAllEpochInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllEpochInfoRequest) ProtoMessage

func (*QueryAllEpochInfoRequest) ProtoMessage()

func (*QueryAllEpochInfoRequest) Reset

func (m *QueryAllEpochInfoRequest) Reset()

func (*QueryAllEpochInfoRequest) Size

func (m *QueryAllEpochInfoRequest) Size() (n int)

func (*QueryAllEpochInfoRequest) String

func (m *QueryAllEpochInfoRequest) String() string

func (*QueryAllEpochInfoRequest) Unmarshal

func (m *QueryAllEpochInfoRequest) Unmarshal(dAtA []byte) error

func (*QueryAllEpochInfoRequest) XXX_DiscardUnknown

func (m *QueryAllEpochInfoRequest) XXX_DiscardUnknown()

func (*QueryAllEpochInfoRequest) XXX_Marshal

func (m *QueryAllEpochInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllEpochInfoRequest) XXX_Merge

func (m *QueryAllEpochInfoRequest) XXX_Merge(src proto.Message)

func (*QueryAllEpochInfoRequest) XXX_Size

func (m *QueryAllEpochInfoRequest) XXX_Size() int

func (*QueryAllEpochInfoRequest) XXX_Unmarshal

func (m *QueryAllEpochInfoRequest) XXX_Unmarshal(b []byte) error

type QueryClient

type QueryClient interface {
	// Queries a EpochInfo by name.
	EpochInfo(ctx context.Context, in *QueryGetEpochInfoRequest, opts ...grpc.CallOption) (*QueryEpochInfoResponse, error)
	// Queries a list of EpochInfo items.
	EpochInfoAll(ctx context.Context, in *QueryAllEpochInfoRequest, opts ...grpc.CallOption) (*QueryEpochInfoAllResponse, error)
}

QueryClient is the client API for Query service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryEpochInfoAllResponse

type QueryEpochInfoAllResponse struct {
	EpochInfo  []EpochInfo         `protobuf:"bytes,1,rep,name=epoch_info,json=epochInfo,proto3" json:"epoch_info"`
	Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryEpochInfoAllResponse is response type for the AllEpochInfo RPC method.

func (*QueryEpochInfoAllResponse) Descriptor

func (*QueryEpochInfoAllResponse) Descriptor() ([]byte, []int)

func (*QueryEpochInfoAllResponse) GetEpochInfo

func (m *QueryEpochInfoAllResponse) GetEpochInfo() []EpochInfo

func (*QueryEpochInfoAllResponse) GetPagination

func (m *QueryEpochInfoAllResponse) GetPagination() *query.PageResponse

func (*QueryEpochInfoAllResponse) Marshal

func (m *QueryEpochInfoAllResponse) Marshal() (dAtA []byte, err error)

func (*QueryEpochInfoAllResponse) MarshalTo

func (m *QueryEpochInfoAllResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryEpochInfoAllResponse) MarshalToSizedBuffer

func (m *QueryEpochInfoAllResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryEpochInfoAllResponse) ProtoMessage

func (*QueryEpochInfoAllResponse) ProtoMessage()

func (*QueryEpochInfoAllResponse) Reset

func (m *QueryEpochInfoAllResponse) Reset()

func (*QueryEpochInfoAllResponse) Size

func (m *QueryEpochInfoAllResponse) Size() (n int)

func (*QueryEpochInfoAllResponse) String

func (m *QueryEpochInfoAllResponse) String() string

func (*QueryEpochInfoAllResponse) Unmarshal

func (m *QueryEpochInfoAllResponse) Unmarshal(dAtA []byte) error

func (*QueryEpochInfoAllResponse) XXX_DiscardUnknown

func (m *QueryEpochInfoAllResponse) XXX_DiscardUnknown()

func (*QueryEpochInfoAllResponse) XXX_Marshal

func (m *QueryEpochInfoAllResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryEpochInfoAllResponse) XXX_Merge

func (m *QueryEpochInfoAllResponse) XXX_Merge(src proto.Message)

func (*QueryEpochInfoAllResponse) XXX_Size

func (m *QueryEpochInfoAllResponse) XXX_Size() int

func (*QueryEpochInfoAllResponse) XXX_Unmarshal

func (m *QueryEpochInfoAllResponse) XXX_Unmarshal(b []byte) error

type QueryEpochInfoResponse

type QueryEpochInfoResponse struct {
	EpochInfo EpochInfo `protobuf:"bytes,1,opt,name=epoch_info,json=epochInfo,proto3" json:"epoch_info"`
}

QueryEpochInfoResponse is response type for the GetEpochInfo RPC method.

func (*QueryEpochInfoResponse) Descriptor

func (*QueryEpochInfoResponse) Descriptor() ([]byte, []int)

func (*QueryEpochInfoResponse) GetEpochInfo

func (m *QueryEpochInfoResponse) GetEpochInfo() EpochInfo

func (*QueryEpochInfoResponse) Marshal

func (m *QueryEpochInfoResponse) Marshal() (dAtA []byte, err error)

func (*QueryEpochInfoResponse) MarshalTo

func (m *QueryEpochInfoResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryEpochInfoResponse) MarshalToSizedBuffer

func (m *QueryEpochInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryEpochInfoResponse) ProtoMessage

func (*QueryEpochInfoResponse) ProtoMessage()

func (*QueryEpochInfoResponse) Reset

func (m *QueryEpochInfoResponse) Reset()

func (*QueryEpochInfoResponse) Size

func (m *QueryEpochInfoResponse) Size() (n int)

func (*QueryEpochInfoResponse) String

func (m *QueryEpochInfoResponse) String() string

func (*QueryEpochInfoResponse) Unmarshal

func (m *QueryEpochInfoResponse) Unmarshal(dAtA []byte) error

func (*QueryEpochInfoResponse) XXX_DiscardUnknown

func (m *QueryEpochInfoResponse) XXX_DiscardUnknown()

func (*QueryEpochInfoResponse) XXX_Marshal

func (m *QueryEpochInfoResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryEpochInfoResponse) XXX_Merge

func (m *QueryEpochInfoResponse) XXX_Merge(src proto.Message)

func (*QueryEpochInfoResponse) XXX_Size

func (m *QueryEpochInfoResponse) XXX_Size() int

func (*QueryEpochInfoResponse) XXX_Unmarshal

func (m *QueryEpochInfoResponse) XXX_Unmarshal(b []byte) error

type QueryGetEpochInfoRequest

type QueryGetEpochInfoRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}

QueryGetEpochInfoRequest is request type for the GetEpochInfo RPC method.

func (*QueryGetEpochInfoRequest) Descriptor

func (*QueryGetEpochInfoRequest) Descriptor() ([]byte, []int)

func (*QueryGetEpochInfoRequest) GetName

func (m *QueryGetEpochInfoRequest) GetName() string

func (*QueryGetEpochInfoRequest) Marshal

func (m *QueryGetEpochInfoRequest) Marshal() (dAtA []byte, err error)

func (*QueryGetEpochInfoRequest) MarshalTo

func (m *QueryGetEpochInfoRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryGetEpochInfoRequest) MarshalToSizedBuffer

func (m *QueryGetEpochInfoRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryGetEpochInfoRequest) ProtoMessage

func (*QueryGetEpochInfoRequest) ProtoMessage()

func (*QueryGetEpochInfoRequest) Reset

func (m *QueryGetEpochInfoRequest) Reset()

func (*QueryGetEpochInfoRequest) Size

func (m *QueryGetEpochInfoRequest) Size() (n int)

func (*QueryGetEpochInfoRequest) String

func (m *QueryGetEpochInfoRequest) String() string

func (*QueryGetEpochInfoRequest) Unmarshal

func (m *QueryGetEpochInfoRequest) Unmarshal(dAtA []byte) error

func (*QueryGetEpochInfoRequest) XXX_DiscardUnknown

func (m *QueryGetEpochInfoRequest) XXX_DiscardUnknown()

func (*QueryGetEpochInfoRequest) XXX_Marshal

func (m *QueryGetEpochInfoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryGetEpochInfoRequest) XXX_Merge

func (m *QueryGetEpochInfoRequest) XXX_Merge(src proto.Message)

func (*QueryGetEpochInfoRequest) XXX_Size

func (m *QueryGetEpochInfoRequest) XXX_Size() int

func (*QueryGetEpochInfoRequest) XXX_Unmarshal

func (m *QueryGetEpochInfoRequest) XXX_Unmarshal(b []byte) error

type QueryServer

type QueryServer interface {
	// Queries a EpochInfo by name.
	EpochInfo(context.Context, *QueryGetEpochInfoRequest) (*QueryEpochInfoResponse, error)
	// Queries a list of EpochInfo items.
	EpochInfoAll(context.Context, *QueryAllEpochInfoRequest) (*QueryEpochInfoAllResponse, error)
}

QueryServer is the server API for Query service.

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

func (*UnimplementedQueryServer) EpochInfo

func (*UnimplementedQueryServer) EpochInfoAll

Jump to

Keyboard shortcuts

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