api

package
v0.0.0-...-477d63b Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package api provides the HTTP interface.

Index

Constants

View Source
const BackgroundCalculationTotalTimeout = time.Second * 60 * 5

BackgroundCalculationTotalTimeout is the time a Refresh operation of single http result may take.

View Source
const CacheRefreshSleepPerRound = time.Second * 30

CacheRefreshSleepPerRound is the delay between cache recalculations.

View Source
const CacheRefreshSleepPerRoundDurringCatchup = time.Second * 60 * 10
View Source
const CacheRefreshStartupSleep = time.Second * 2

CacheRefreshStartupSleep is the delay at startup before starting the first cache refresh.

Variables

View Source
var CacheLogger = midlog.LoggerForModule("cache")
View Source
var GlobalCacheStore cacheStore
View Source
var Handler http.Handler

Handler serves the entire API.

View Source
var ShowBonds bool = false

TODO(huginn): remove when bonds are fixed

Functions

func CreateAndRegisterCache

func CreateAndRegisterCache(f RefreshFunc, name string) *cache

func GetPPYFromBuckets

func GetPPYFromBuckets(b db.Buckets) float64

func GetPoolAPRs

func GetPoolAPRs(ctx context.Context,
	depthsNow timeseries.DepthMap, lpUnitsNow map[string]int64, pools []string,
	aprStartTime db.Nano, now db.Nano) (
	map[string]float64, error)

func GetSinglePoolAPR

func GetSinglePoolAPR(ctx context.Context,
	depths timeseries.PoolDepths, lpUnits int64, pool string, start db.Nano, now db.Nano) (
	float64, error)

func InitHandler

func InitHandler(nodeURL string)

InitHandler inits API main handler

func TimestampAndHeight

func TimestampAndHeight(ctx context.Context, id int64) (
	height int64, timestamp db.Nano, err error)

Types

type DebugBlockResponse

type DebugBlockResponse struct {
	Timestamp db.Nano `json:"timestamp"`
	Height    int64   `json:"blockHeight"`
	// As long as we use `debug` endpoint for debugging only
	// types for block results are not needed to be defined in detail and can be "generic"
	Results interface{} `json:"blockResults"`
}

type EarningsInfo

type EarningsInfo struct {
	Earnings                   int64
	AnnualEarningsAsPercentage float64
}

type Health

type Health struct {
	CatchingUp    bool  `json:"catching_up"`
	Database      bool  `json:"database"`
	ScannerHeight int64 `json:"scannerHeight,string"`
}

TODO(HooriRn): this struct is not needed since the graphql depracation, replace with the corresponding oapi version. (delete-graphql)

type Node

type Node struct {
	Secp256K1 string `json:"secp256k1"`
	Ed25519   string `json:"ed25519"`
}

TODO(HooriRn): this struct is not needed since the graphql depracation, replace with the corresponding oapi version. (delete-graphql)

type RefreshFunc

type RefreshFunc func(ctx context.Context, w io.Writer) error

type SaverData

type SaverData struct {
	SaversUnits int64
	SaversDepth int64
}

type ThornameReverseLookupFunc

type ThornameReverseLookupFunc func(ctx context.Context, addr string) (names []string, err error)

Jump to

Keyboard shortcuts

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