api

package
v1.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// UrlParameterWithLogs represents the name of an URL parameter to query logs per hyperBlock
	UrlParameterWithLogs = "withLogs"
	// UrlParameterNotarizedAtSource represents the name of an URL parameter to query hyper blocks which are notarized at source
	UrlParameterNotarizedAtSource = "notarizedAtSource"
	// UrlParameterWithAlteredAccounts represents the name of an URL parameter to query altered accounts per hyperBlock
	UrlParameterWithAlteredAccounts = "withAlteredAccounts"
	// UrlParameterTokens represents the name of an URL parameter to query altered accounts with tokens
	UrlParameterTokens = "tokens"
)

Variables

This section is empty.

Functions

func NewDefaultHttpClient

func NewDefaultHttpClient(requestTimeoutSec uint64) *httpClient

NewDefaultHttpClient will create a default http client which can be queried to GET url responses

func NewHyperBlockProxy

func NewHyperBlockProxy(
	hyperBlockFacade HyperBlockFacadeHandler,
	cfg config.Config,
) (*hyperBlockProxy, error)

NewHyperBlockProxy will create a covalent proxy, able to fetch hyper block requests from Multiversx and return them in covalent format

func NewMultiversxHyperBlockEndPoint

func NewMultiversxHyperBlockEndPoint(httpClient HTTPClient) (*multiversxHyperBlockEndPoint, error)

NewMultiversxHyperBlockEndPoint will create a handler which can fetch hyper blocks from Multiversx gateway

Types

type CovalentHyperBlockApiResponse

type CovalentHyperBlockApiResponse struct {
	Data  []byte     `json:"data"`
	Error string     `json:"error"`
	Code  ReturnCode `json:"code"`
}

CovalentHyperBlockApiResponse is the hyper block dto response for Covalent

type CovalentHyperBlocksApiResponse

type CovalentHyperBlocksApiResponse struct {
	Data  [][]byte   `json:"data"`
	Error string     `json:"error"`
	Code  ReturnCode `json:"code"`
}

CovalentHyperBlocksApiResponse is the hyper blocks dto response for Covalent

type HTTPClient

type HTTPClient interface {
	Get(url string) (resp *http.Response, err error)
}

HTTPClient defines what a client which should be able to GET requests should do

type HTTPServer

type HTTPServer interface {
	ListenAndServe() error
	Shutdown(ctx context.Context) error
	Close() error
}

HTTPServer defines what an http server should do

type HyperBlockFacadeHandler

type HyperBlockFacadeHandler interface {
	GetHyperBlockByNonce(nonce uint64, options config.HyperBlockQueryOptions) (*CovalentHyperBlockApiResponse, error)
	GetHyperBlockByHash(hash string, options config.HyperBlockQueryOptions) (*CovalentHyperBlockApiResponse, error)
	GetHyperBlocksByInterval(noncesInterval *Interval, options config.HyperBlocksQueryOptions) (*CovalentHyperBlocksApiResponse, error)
}

HyperBlockFacadeHandler defines the actions needed for fetching of hyperBlocks from Multiversx proxy in covalent format

type HyperBlockProxy

type HyperBlockProxy interface {
	GetHyperBlockByNonce(c *gin.Context)
	GetHyperBlockByHash(c *gin.Context)
	GetHyperBlocksByInterval(c *gin.Context)
}

HyperBlockProxy is the covalent proxy. It should be able to fetch hyper blocks from Multiversx proxy(json format), process them and provide avro schema defined hyper blocks(as byte array).

type Interval

type Interval struct {
	Start uint64
	End   uint64
}

Interval defines a [start,end] interval

type MultiversxHyperBlockApiResponse

type MultiversxHyperBlockApiResponse struct {
	Data  MultiversxHyperBlockApiResponsePayload `json:"data"`
	Error string                                 `json:"error"`
	Code  ReturnCode                             `json:"code"`
}

MultiversxHyperBlockApiResponse is the expected hyper block dto response from Multiversx proxy

type MultiversxHyperBlockApiResponsePayload

type MultiversxHyperBlockApiResponsePayload struct {
	HyperBlock hyperBlock.HyperBlock `json:"hyperblock"`
}

MultiversxHyperBlockApiResponsePayload wraps a hyperBlock

type MultiversxHyperBlockEndpointHandler

type MultiversxHyperBlockEndpointHandler interface {
	GetHyperBlock(path string) (*MultiversxHyperBlockApiResponse, error)
}

MultiversxHyperBlockEndpointHandler should fetch hyper block api responses from Multiversx

type ReturnCode

type ReturnCode string

ReturnCode identifies api return codes

const ReturnCodeInternalError ReturnCode = "internal_issue"

ReturnCodeInternalError defines a request which hasn't been executed successfully due to an internal error

const ReturnCodeRequestError ReturnCode = "bad_request"

ReturnCodeRequestError defines a request which hasn't been executed successfully due to a bad request received

const ReturnCodeSuccess ReturnCode = "successful"

ReturnCodeSuccess defines a successful request

Jump to

Keyboard shortcuts

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