leapapi

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 10 Imported by: 1

README

Antelope Leap HTTP Api

Leap HTTP API and hyperion API written in go.

Install package
go get -u github.com/eosswedenorg-go/leapapi@latest
Types

API Request parameters struct

type ReqParams struct {
	Url string
	Host string
}

chain info struct

type Info struct {
	ServerVersion string
	HeadBlockNum int64
	HeadBlockTime time.Time
}

Hyperion health struct (not all fields).

type Health struct {
	VersionHash string
	Health []Service
}

Service struct from Hyperion health

type Service struct {
	Name string
	Status string
	Data map[string]interface{}
	Time int64 // unix timestamp.
}
Functions
func GetInfo(params ReqParams) (Info, error)

Call v1/chain/get_info and return the results.

func GetHealth(params ReqParams) (Health, error)

Call v2/health (hyperion) and return the results.

Author

Henrik Hautakoski - Sw/eden - henrik@eossweden.org

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Json added in v0.2.2

func Json() jsoniter.API

Types

type APIError

type APIError struct {
	Code    int64         `json:"code"`
	Message string        `json:"message"`
	Err     APIErrorInner `json:"error"`
}

func (APIError) Error

func (e APIError) Error() string

func (*APIError) IsEmpty

func (e *APIError) IsEmpty() bool

type APIErrorDetail

type APIErrorDetail struct {
	Message string `json:"message"`
	File    string `json:"file"`
	Line    int64  `json:"line_number"`
	Method  string `json:"method"`
}

type APIErrorInner

type APIErrorInner struct {
	Code    int64            `json:"code"`
	Name    string           `json:"name"`
	What    string           `json:"what"`
	Details []APIErrorDetail `json:"details"`
}

type Client

type Client struct {
	Url  string
	Host string
	// contains filtered or unexported fields
}

func New

func New(url string) *Client

func (*Client) GetHealth

func (c *Client) GetHealth(ctx context.Context) (health Health, err error)
Health - Fetches "/v2/health" from API

---------------------------------------------------------

func (*Client) GetInfo

func (c *Client) GetInfo(ctx context.Context) (info Info, err error)
GetInfo - Fetches "/v1/chain/get_info" from API

---------------------------------------------------------

type HTTPError

type HTTPError struct {
	Code    int
	Message string
}

func (HTTPError) Error

func (e HTTPError) Error() string

type Health

type Health struct {
	Version     string                 `json:"version"`
	VersionHash string                 `json:"version_hash"`
	Health      []Service              `json:"health"`
	Features    map[string]interface{} `json:"features"`
	QueryTime   float32                `json:"query_time_ms"`
}

/v2/health format

type Info

type Info struct {
	ServerVersion             string    `json:"server_version"`
	ServerVersionString       string    `json:"server_version_string"`
	ServerFullVersionString   string    `json:"server_full_version_string"`
	ChainID                   string    `json:"chain_id"`
	HeadBlockID               string    `json:"head_block_id"`
	HeadBlockNum              int64     `json:"head_block_num"`
	HeadBlockTime             time.Time `json:"head_block_time"`
	HeadBlockProducer         string    `json:"head_block_producer"`
	LastIrreversableBlockNum  int64     `json:"last_irreversible_block_num"`
	LastIrreversableBlockID   string    `json:"last_irreversible_block_id"`
	LastIrreversableBlockTime time.Time `json:"last_irreversible_block_time,omitempty"`
	VirtualBlockCPULimit      int64     `json:"virtual_block_cpu_limit"`
	VirtualBlockNETLimit      int64     `json:"virtual_block_net_limit"`
	BlockCPULimit             int64     `json:"block_cpu_limit"`
	BlockNETLimit             int64     `json:"block_net_limit"`
	TotalCPUWeight            int64     `json:"total_cpu_weigth,omitempty"`
	TotalNETWeight            int64     `json:"total_net_weigth,omitempty"`
	ForkDBHeadBlockID         string    `json:"fork_db_head_block_id"`
	ForkDBHeadBlockNum        int64     `json:"fork_db_head_block_num"`
	EarliestAvailableBlockNum int64     `json:"earliest_available_block_num,omitempty"`
}

get_info format

type Service

type Service struct {
	Name   string
	Status string
	Data   map[string]interface{}
	Time   time.Time
}

Service struct from /v2/health

func (*Service) UnmarshalJSON

func (s *Service) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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