types

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package types translates gRPC into RESTful JSON APIs.

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	EventTypeEpochEnd   = "epoch_end"
	EventTypeEpochStart = "epoch_start"

	AttributeEpochNumber    = "epoch_number"
	AttributeEpochStartTime = "start_time"
)
View Source
const (
	// ModuleName defines the module name.
	ModuleName = "epochs"

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

	// RouterKey is the message route for slashing.
	RouterKey = ModuleName

	// QuerierRoute defines the module's query routing key.
	QuerierRoute = ModuleName
)
View Source
const DefaultIndex uint64 = 1

DefaultIndex is the default capability global index.

Variables

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 KeyPrefixEpoch = []byte{0x01}

KeyPrefixEpoch defines prefix key for storing epochs.

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 EpochHooks

type EpochHooks interface {
	// the first block whose timestamp is after the duration is counted as the end of the epoch
	AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error
	// new epoch is next block of epoch end block
	BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error
}

type EpochInfo

type EpochInfo 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=start_time,json=startTime,proto3,stdtime" json:"start_time" 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 (current_epoch=1) is defined as
	// the first block whose blocktime is greater than the EpochInfo start_time.
	CurrentEpoch int64 `protobuf:"varint,4,opt,name=current_epoch,json=currentEpoch,proto3" json:"current_epoch,omitempty"`
	// current_epoch_start_time describes the start time of the current timer
	// interval. The interval is (current_epoch_start_time,
	// current_epoch_start_time + duration] When the timer ticks, this is set to
	// current_epoch_start_time = last_epoch_start_time + duration only one timer
	// tick for a given identifier can occur per block.
	//
	// NOTE! The current_epoch_start_time may diverge significantly from the
	// wall-clock time the epoch began at. Wall-clock time of epoch start may be
	// >> current_epoch_start_time. Suppose current_epoch_start_time = 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 `` /* 158-byte string literal not displayed */
	// epoch_counting_started is a boolean, that indicates whether this
	// epoch timer has began yet.
	EpochCountingStarted bool `protobuf:"varint,6,opt,name=epoch_counting_started,json=epochCountingStarted,proto3" json:"epoch_counting_started,omitempty"`
	// 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 `` /* 135-byte string literal not displayed */
}

EpochInfo is a struct that describes the data going into a timer defined by the x/epochs module.

func NewGenesisEpochInfo

func NewGenesisEpochInfo(identifier string, duration time.Duration) EpochInfo

func (*EpochInfo) Descriptor

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

func (*EpochInfo) GetCurrentEpoch

func (m *EpochInfo) GetCurrentEpoch() int64

func (*EpochInfo) GetCurrentEpochStartHeight

func (m *EpochInfo) GetCurrentEpochStartHeight() int64

func (*EpochInfo) GetCurrentEpochStartTime

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

func (*EpochInfo) GetDuration

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

func (*EpochInfo) GetEpochCountingStarted

func (m *EpochInfo) GetEpochCountingStarted() bool

func (*EpochInfo) GetIdentifier

func (m *EpochInfo) GetIdentifier() string

func (*EpochInfo) GetStartTime

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

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 also validates 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 GenesisState

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

GenesisState defines the epochs module's genesis state.

func DefaultGenesis

func DefaultGenesis() *GenesisState

DefaultGenesis returns the default Capability genesis state.

func NewGenesisState

func NewGenesisState(epochs []EpochInfo) *GenesisState

func (*GenesisState) Descriptor

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

func (*GenesisState) GetEpochs

func (m *GenesisState) GetEpochs() []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 MultiEpochHooks

type MultiEpochHooks []EpochHooks

combine multiple gamm hooks, all hook functions are run in array sequence.

func NewMultiEpochHooks

func NewMultiEpochHooks(hooks ...EpochHooks) MultiEpochHooks

func (MultiEpochHooks) AfterEpochEnd

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

AfterEpochEnd is called when epoch is going to be ended, epochNumber is the number of epoch that is ending.

func (MultiEpochHooks) BeforeEpochStart

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

BeforeEpochStart is called when epoch is going to be started, epochNumber is the number of epoch that is starting.

type QueryClient

type QueryClient interface {
	// EpochInfos provide running epochInfos
	EpochInfos(ctx context.Context, in *QueryEpochsInfoRequest, opts ...grpc.CallOption) (*QueryEpochsInfoResponse, error)
	// CurrentEpoch provide current epoch of specified identifier
	CurrentEpoch(ctx context.Context, in *QueryCurrentEpochRequest, opts ...grpc.CallOption) (*QueryCurrentEpochResponse, 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 QueryEpochsInfoRequest

type QueryEpochsInfoRequest struct {
}

func (*QueryEpochsInfoRequest) Descriptor

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

func (*QueryEpochsInfoRequest) Marshal

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

func (*QueryEpochsInfoRequest) MarshalTo

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

func (*QueryEpochsInfoRequest) MarshalToSizedBuffer

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

func (*QueryEpochsInfoRequest) ProtoMessage

func (*QueryEpochsInfoRequest) ProtoMessage()

func (*QueryEpochsInfoRequest) Reset

func (m *QueryEpochsInfoRequest) Reset()

func (*QueryEpochsInfoRequest) Size

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

func (*QueryEpochsInfoRequest) String

func (m *QueryEpochsInfoRequest) String() string

func (*QueryEpochsInfoRequest) Unmarshal

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

func (*QueryEpochsInfoRequest) XXX_DiscardUnknown

func (m *QueryEpochsInfoRequest) XXX_DiscardUnknown()

func (*QueryEpochsInfoRequest) XXX_Marshal

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

func (*QueryEpochsInfoRequest) XXX_Merge

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

func (*QueryEpochsInfoRequest) XXX_Size

func (m *QueryEpochsInfoRequest) XXX_Size() int

func (*QueryEpochsInfoRequest) XXX_Unmarshal

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

type QueryEpochsInfoResponse

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

func (*QueryEpochsInfoResponse) Descriptor

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

func (*QueryEpochsInfoResponse) GetEpochs

func (m *QueryEpochsInfoResponse) GetEpochs() []EpochInfo

func (*QueryEpochsInfoResponse) Marshal

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

func (*QueryEpochsInfoResponse) MarshalTo

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

func (*QueryEpochsInfoResponse) MarshalToSizedBuffer

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

func (*QueryEpochsInfoResponse) ProtoMessage

func (*QueryEpochsInfoResponse) ProtoMessage()

func (*QueryEpochsInfoResponse) Reset

func (m *QueryEpochsInfoResponse) Reset()

func (*QueryEpochsInfoResponse) Size

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

func (*QueryEpochsInfoResponse) String

func (m *QueryEpochsInfoResponse) String() string

func (*QueryEpochsInfoResponse) Unmarshal

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

func (*QueryEpochsInfoResponse) XXX_DiscardUnknown

func (m *QueryEpochsInfoResponse) XXX_DiscardUnknown()

func (*QueryEpochsInfoResponse) XXX_Marshal

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

func (*QueryEpochsInfoResponse) XXX_Merge

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

func (*QueryEpochsInfoResponse) XXX_Size

func (m *QueryEpochsInfoResponse) XXX_Size() int

func (*QueryEpochsInfoResponse) XXX_Unmarshal

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

type QueryServer

type QueryServer interface {
	// EpochInfos provide running epochInfos
	EpochInfos(context.Context, *QueryEpochsInfoRequest) (*QueryEpochsInfoResponse, error)
	// CurrentEpoch provide current epoch of specified identifier
	CurrentEpoch(context.Context, *QueryCurrentEpochRequest) (*QueryCurrentEpochResponse, 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) EpochInfos

Jump to

Keyboard shortcuts

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