random

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRandomRequest

type CreateRandomRequest struct {
	CallbackAddress string  `json:"callback_address"`
	CallbackMethod  string  `json:"callback_method"`
	Seed            string  `json:"seed"`
	NumBytes        int     `json:"num_bytes"`
	DelayBlocks     int     `json:"delay_blocks"`
	GasFee          float64 `json:"gas_fee"`
}

CreateRandomRequest is the request body for creating a random number request

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles random number generation API endpoints

func NewHandler

func NewHandler(randomService *random.Service, logger *logger.Logger) *Handler

NewHandler creates a new random handler

func (*Handler) CreateRandomRequest

func (h *Handler) CreateRandomRequest(c *gin.Context)

CreateRandomRequest creates a new random number request @Summary Create random request @Description Create a new random number request @Tags random @Accept json @Produce json @Param request body CreateRandomRequest true "Random Request" @Success 201 {object} RandomResponse @Failure 400 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/random/requests [post]

func (*Handler) GenerateRandomNumber

func (h *Handler) GenerateRandomNumber(c *gin.Context)

GenerateRandomNumber generates a new random number (public API) @Summary Generate random number @Description Generate a new random number @Tags public @Accept json @Produce json @Param request body CreateRandomRequest true "Random Request" @Success 201 {object} RandomResponse @Failure 400 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/public/random [post]

func (*Handler) GetRandomAnalysis

func (h *Handler) GetRandomAnalysis(c *gin.Context)

GetRandomAnalysis gets statistics for random number generation @Summary Get random analysis @Description Get statistics for random number generation @Tags random @Produce json @Success 200 {object} map[string]interface{} @Failure 500 {object} common.ErrorResponse @Router /api/v1/random/analysis [get]

func (*Handler) GetRandomNumber

func (h *Handler) GetRandomNumber(c *gin.Context)

GetRandomNumber gets a random number by ID (public API) @Summary Get random number @Description Get a specific random number by ID @Tags public @Produce json @Param id path int true "Request ID" @Success 200 {object} RandomResponse @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/public/random/{id} [get]

func (*Handler) GetRandomRequest

func (h *Handler) GetRandomRequest(c *gin.Context)

GetRandomRequest gets a random number request by ID @Summary Get random request @Description Get details of a specific random number request @Tags random @Produce json @Param id path int true "Request ID" @Success 200 {object} RandomResponse @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/random/requests/{id} [get]

func (*Handler) ListRandomRequests

func (h *Handler) ListRandomRequests(c *gin.Context)

ListRandomRequests lists all random number requests for a user @Summary List random requests @Description Get a list of random number requests for the authenticated user @Tags random @Produce json @Param page query int false "Page number" default(1) @Param limit query int false "Items per page" default(20) @Success 200 {array} RandomResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/random/requests [get]

func (*Handler) Register

func (h *Handler) Register(router *gin.RouterGroup)

Register registers random number generation routes with the given router

func (*Handler) VerifyRandomNumber

func (h *Handler) VerifyRandomNumber(c *gin.Context)

VerifyRandomNumber verifies a random number (public API) @Summary Verify random number @Description Verify a random number against its commitment @Tags public @Accept json @Produce json @Param id path int true "Request ID" @Param request body VerifyRequest true "Verification Data" @Success 200 {object} map[string]bool @Failure 400 {object} common.ErrorResponse @Failure 404 {object} common.ErrorResponse @Failure 500 {object} common.ErrorResponse @Router /api/v1/public/random/{id}/verify [get]

type RandomResponse

type RandomResponse struct {
	ID              int    `json:"id"`
	Status          string `json:"status"`
	RandomNumber    string `json:"random_number,omitempty"`
	CommitmentHash  string `json:"commitment_hash,omitempty"`
	CallbackAddress string `json:"callback_address,omitempty"`
	NumBytes        int    `json:"num_bytes"`
	CreatedAt       string `json:"created_at"`
	RevealedAt      string `json:"revealed_at,omitempty"`
}

RandomResponse is the response body for a random number

type VerifyRequest

type VerifyRequest struct {
	RandomNumber string `json:"random_number"`
	Proof        string `json:"proof"`
}

VerifyRequest is the request body for verifying a random number

Jump to

Keyboard shortcuts

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