types

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	// ModuleName defines the module name
	ModuleName = "epoch"

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

	// RouterKey defines the module's message routing key
	RouterKey = ModuleName

	// MemStoreKey defines the in-memory store key
	MemStoreKey = "mem_epoch"
)
View Source
const (
	EventTypeEpochEnd   = "epoch_end"
	EventTypeEpochStart = "epoch_start"

	AttributeEpochNumber    = "epoch_number"
	AttributeEpochStartTime = "start_time"
	AttributeEpochProvision = "epoch_provision"
)
View Source
const DefaultIndex uint64 = 1

DefaultIndex is the default global index

Variables

View Source
var (
	ErrInvalidLengthEpoch        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowEpoch          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupEpoch = fmt.Errorf("proto: unexpected end of group")
)
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 (
	ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error")
)

x/epoch module sentinel errors

View Source
var KeyPrefixEpoch = []byte{0x01}

Functions

func KeyPrefix

func KeyPrefix(p string) []byte

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)

func ValidateEpochIdentifierInterface

func ValidateEpochIdentifierInterface(i interface{}) error

func ValidateEpochIdentifierString

func ValidateEpochIdentifierString(s string) error

Types

type Epoch

type Epoch struct {
	// identifier is a unique reference to this particular timer.
	Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
	// start time is the time at which the timer first ever ticks.
	// If start time is in the future, the epoch will not begin until the start
	// time.
	StartTime time.Time `protobuf:"bytes,2,opt,name=startTime,proto3,stdtime" json:"start_time,omitempty" yaml:"start_time"`
	// duration is the time in between epoch ticks.
	// In order for intended behavior to be met, duration should
	// be greater than the chains expected block time.
	// Duration must be non-zero.
	Duration time.Duration `protobuf:"bytes,3,opt,name=duration,proto3,stdduration" json:"duration,omitempty" yaml:"duration"`
	// current epoch is the current epoch number, or in other words,
	// how many times has the timer 'ticked'.
	// The first tick (currentEpoch=1) is defined as
	// the first block whose blocktime is greater than the Epoch startTime.
	CurrentEpoch int64 `protobuf:"varint,4,opt,name=currentEpoch,proto3" json:"current_epoch,omitempty" yaml:"current_epoch"`
	// current epoch start time describes the start time of the current timer
	// interval. The interval is (currentEpochStartTime,
	// ccurrentEpochStartTime + duration] When the timer ticks, this is set to
	// currentEpochStartTime = lastEpochStartTime + duration only one timer
	// tick for a given identifier can occur per block.
	//
	// NOTE! The currentEpochStartTime may diverge significantly from the
	// wall-clock time the epoch began at. Wall-clock time of epoch start may be
	// >> currentEpochStartTime. Suppose currentEpochStartTime = 10,
	// duration = 5. Suppose the chain goes offline at t=14, and comes back online
	// at t=30, and produces blocks at every successive time. (t=31, 32, etc.)
	// * The t=30 block will start the epoch for (10, 15]
	// * The t=31 block will start the epoch for (15, 20]
	// * The t=32 block will start the epoch for (20, 25]
	// * The t=33 block will start the epoch for (25, 30]
	// * The t=34 block will start the epoch for (30, 35]
	// * The **t=36** block will start the epoch for (35, 40]
	CurrentEpochStartTime time.Time `` /* 138-byte string literal not displayed */
	// epoch_counting_started is a boolean, that indicates whether this
	// epoch timer has began yet.
	EpochCountingStarted bool `` /* 126-byte string literal not displayed */
	// current epoch start height is the block height at which the current epoch
	// started. (The block height at which the timer last ticked)
	CurrentEpochStartHeight int64 `` /* 137-byte string literal not displayed */
}

func NewGenesisEpoch

func NewGenesisEpoch(identifier string, duration time.Duration) Epoch

func (*Epoch) Descriptor

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

func (*Epoch) GetCurrentEpoch

func (m *Epoch) GetCurrentEpoch() int64

func (*Epoch) GetCurrentEpochStartHeight

func (m *Epoch) GetCurrentEpochStartHeight() int64

func (*Epoch) GetCurrentEpochStartTime

func (m *Epoch) GetCurrentEpochStartTime() time.Time

func (*Epoch) GetDuration

func (m *Epoch) GetDuration() time.Duration

func (*Epoch) GetEpochCountingStarted

func (m *Epoch) GetEpochCountingStarted() bool

func (*Epoch) GetIdentifier

func (m *Epoch) GetIdentifier() string

func (*Epoch) GetStartTime

func (m *Epoch) GetStartTime() time.Time

func (*Epoch) Marshal

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

func (*Epoch) MarshalTo

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

func (*Epoch) MarshalToSizedBuffer

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

func (*Epoch) ProtoMessage

func (*Epoch) ProtoMessage()

func (*Epoch) Reset

func (m *Epoch) Reset()

func (*Epoch) Size

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

func (*Epoch) String

func (m *Epoch) String() string

func (*Epoch) Unmarshal

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

func (Epoch) Validate

func (epoch Epoch) Validate() error

func (*Epoch) XXX_DiscardUnknown

func (m *Epoch) XXX_DiscardUnknown()

func (*Epoch) XXX_Marshal

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

func (*Epoch) XXX_Merge

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

func (*Epoch) XXX_Size

func (m *Epoch) XXX_Size() int

func (*Epoch) XXX_Unmarshal

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

type EpochHooks

type EpochHooks interface {
	AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) error
	BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber int64) error
}

type GenesisState

type GenesisState struct {
	Epochs []Epoch `protobuf:"bytes,1,rep,name=epochs,proto3" json:"epochs"`
}

GenesisState defines the epoch module's genesis state.

func DefaultGenesis

func DefaultGenesis() *GenesisState

DefaultGenesis returns the default genesis state

func NewGenesisState

func NewGenesisState(epochs []Epoch) *GenesisState

func (*GenesisState) Descriptor

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

func (*GenesisState) GetEpochs

func (m *GenesisState) GetEpochs() []Epoch

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 MultiEpochHooks

type MultiEpochHooks []EpochHooks

func NewMultiEpochHooks

func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks

func (MultiEpochHooks) AfterEpochEnd

func (h MultiEpochHooks) AfterEpochEnd(ctx sdk.Context, identifier string, epochNumber int64) error

func (MultiEpochHooks) BeforeEpochStart

func (h MultiEpochHooks) BeforeEpochStart(ctx sdk.Context, identifier string, epochNumber int64) error

type QueryAllEpochRequest

type QueryAllEpochRequest struct {
}

func (*QueryAllEpochRequest) Descriptor

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

func (*QueryAllEpochRequest) Marshal

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

func (*QueryAllEpochRequest) MarshalTo

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

func (*QueryAllEpochRequest) MarshalToSizedBuffer

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

func (*QueryAllEpochRequest) ProtoMessage

func (*QueryAllEpochRequest) ProtoMessage()

func (*QueryAllEpochRequest) Reset

func (m *QueryAllEpochRequest) Reset()

func (*QueryAllEpochRequest) Size

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

func (*QueryAllEpochRequest) String

func (m *QueryAllEpochRequest) String() string

func (*QueryAllEpochRequest) Unmarshal

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

func (*QueryAllEpochRequest) XXX_DiscardUnknown

func (m *QueryAllEpochRequest) XXX_DiscardUnknown()

func (*QueryAllEpochRequest) XXX_Marshal

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

func (*QueryAllEpochRequest) XXX_Merge

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

func (*QueryAllEpochRequest) XXX_Size

func (m *QueryAllEpochRequest) XXX_Size() int

func (*QueryAllEpochRequest) XXX_Unmarshal

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

type QueryAllEpochResponse

type QueryAllEpochResponse struct {
	Epochs []Epoch `protobuf:"bytes,1,rep,name=Epochs,proto3" json:"Epochs"`
}

func (*QueryAllEpochResponse) Descriptor

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

func (*QueryAllEpochResponse) GetEpochs

func (m *QueryAllEpochResponse) GetEpochs() []Epoch

func (*QueryAllEpochResponse) Marshal

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

func (*QueryAllEpochResponse) MarshalTo

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

func (*QueryAllEpochResponse) MarshalToSizedBuffer

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

func (*QueryAllEpochResponse) ProtoMessage

func (*QueryAllEpochResponse) ProtoMessage()

func (*QueryAllEpochResponse) Reset

func (m *QueryAllEpochResponse) Reset()

func (*QueryAllEpochResponse) Size

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

func (*QueryAllEpochResponse) String

func (m *QueryAllEpochResponse) String() string

func (*QueryAllEpochResponse) Unmarshal

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

func (*QueryAllEpochResponse) XXX_DiscardUnknown

func (m *QueryAllEpochResponse) XXX_DiscardUnknown()

func (*QueryAllEpochResponse) XXX_Marshal

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

func (*QueryAllEpochResponse) XXX_Merge

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

func (*QueryAllEpochResponse) XXX_Size

func (m *QueryAllEpochResponse) XXX_Size() int

func (*QueryAllEpochResponse) XXX_Unmarshal

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

type QueryClient

type QueryClient interface {
	// Queries current Epoch.
	CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, error)
	// Queries a list of Epoch items.
	EpochAll(ctx context.Context, in *QueryAllEpochRequest, opts ...grpc.CallOption) (*QueryAllEpochResponse, 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 QueryCurrentEpochRequest

type QueryCurrentEpochRequest struct {
	Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
}

func (*QueryCurrentEpochRequest) Descriptor

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

func (*QueryCurrentEpochRequest) GetIdentifier

func (m *QueryCurrentEpochRequest) GetIdentifier() string

func (*QueryCurrentEpochRequest) Marshal

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

func (*QueryCurrentEpochRequest) MarshalTo

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

func (*QueryCurrentEpochRequest) MarshalToSizedBuffer

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

func (*QueryCurrentEpochRequest) ProtoMessage

func (*QueryCurrentEpochRequest) ProtoMessage()

func (*QueryCurrentEpochRequest) Reset

func (m *QueryCurrentEpochRequest) Reset()

func (*QueryCurrentEpochRequest) Size

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

func (*QueryCurrentEpochRequest) String

func (m *QueryCurrentEpochRequest) String() string

func (*QueryCurrentEpochRequest) Unmarshal

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

func (*QueryCurrentEpochRequest) XXX_DiscardUnknown

func (m *QueryCurrentEpochRequest) XXX_DiscardUnknown()

func (*QueryCurrentEpochRequest) XXX_Marshal

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

func (*QueryCurrentEpochRequest) XXX_Merge

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

func (*QueryCurrentEpochRequest) XXX_Size

func (m *QueryCurrentEpochRequest) XXX_Size() int

func (*QueryCurrentEpochRequest) XXX_Unmarshal

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

type QueryCurrentEpochResponse

type QueryCurrentEpochResponse struct {
	CurrentEpoch int64 `protobuf:"varint,1,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
}

func (*QueryCurrentEpochResponse) Descriptor

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

func (*QueryCurrentEpochResponse) GetCurrentEpoch

func (m *QueryCurrentEpochResponse) GetCurrentEpoch() int64

func (*QueryCurrentEpochResponse) Marshal

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

func (*QueryCurrentEpochResponse) MarshalTo

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

func (*QueryCurrentEpochResponse) MarshalToSizedBuffer

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

func (*QueryCurrentEpochResponse) ProtoMessage

func (*QueryCurrentEpochResponse) ProtoMessage()

func (*QueryCurrentEpochResponse) Reset

func (m *QueryCurrentEpochResponse) Reset()

func (*QueryCurrentEpochResponse) Size

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

func (*QueryCurrentEpochResponse) String

func (m *QueryCurrentEpochResponse) String() string

func (*QueryCurrentEpochResponse) Unmarshal

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

func (*QueryCurrentEpochResponse) XXX_DiscardUnknown

func (m *QueryCurrentEpochResponse) XXX_DiscardUnknown()

func (*QueryCurrentEpochResponse) XXX_Marshal

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

func (*QueryCurrentEpochResponse) XXX_Merge

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

func (*QueryCurrentEpochResponse) XXX_Size

func (m *QueryCurrentEpochResponse) XXX_Size() int

func (*QueryCurrentEpochResponse) XXX_Unmarshal

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

type QueryServer

type QueryServer interface {
	// Queries current Epoch.
	CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, error)
	// Queries a list of Epoch items.
	EpochAll(context.Context, *QueryAllEpochRequest) (*QueryAllEpochResponse, 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) CurrentEpoch

func (*UnimplementedQueryServer) EpochAll

Jump to

Keyboard shortcuts

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