api

package
v0.0.0-...-58bdd35 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2023 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AVMName     = "avm"
	XChainAlias = "v"
	PVMName     = "pvm"
	PChainAlias = "m"
	CVMName     = "cvm"
	CChainAlias = "m"
)
View Source
const (
	DefaultLimit       = 1000
	DefaultOffsetLimit = 10000
)
View Source
const (
	MetricCount  = "api_count"
	MetricMillis = "api_millis"
)
View Source
const (
	MetricTransactionsCount   = "api_transactions_count"
	MetricTransactionsMillis  = "api_transactions_millis"
	MetricCTransactionsCount  = "api_ctransactions_count"
	MetricCTransactionsMillis = "api_ctransactions_millis"
	MetricAddressesCount      = "api_addresses_count"
	MetricAddressesMillis     = "api_addresses_millis"
	MetricAddressChainsCount  = "api_address_chains_count"
	MetricAddressChainsMillis = "api_address_chains_millis"
	MetricAggregateCount      = "api_aggregate_count"
	MetricAggregateMillis     = "api_aggregate_millis"
	MetricAssetCount          = "api_asset_count"
	MetricAssetMillis         = "api_asset_millis"
	MetricSearchCount         = "api_search_count"
	MetricSearchMillis        = "api_search_millis"
)

Variables

View Source
var ErrCacheableFnFailed = errors.New("failed to load resource")

ErrCacheableFnFailed is returned when the execution of a CacheableFn fails.

Functions

func AddV2Routes

func AddV2Routes(ctx *Context, router *web.Router, path string, indexBytes []byte, chainID *ids.ID)

AddV2Routes mounts a V2 API router at the given path, displaying the given indexBytes at the root. If chainID is not nil the handlers run in v1 compatible mode where the `version` param is set to "1" and requests to default to filtering by the given chainID.

func ParseGetJSON

func ParseGetJSON(r *web.Request, n int64) (url.Values, error)

func WriteErr

func WriteErr(w http.ResponseWriter, code int, msg string)

WriteErr writes the given error message to the http response

func WriteJSON

func WriteJSON(w http.ResponseWriter, msg []byte)

WriteJSON writes the given bytes to the http response as JSON

Types

type Context

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

Context is the base context for APIs in the magellan systems

func (*Context) NetworkID

func (c *Context) NetworkID() uint32

NetworkID returns the networkID this request is for

func (*Context) WriteCacheable

func (c *Context) WriteCacheable(w http.ResponseWriter, cacheable caching.Cacheable)

WriteCacheable writes to the http response the output of the given Cacheable's function, either from the cache or from a new execution of the function

func (*Context) WriteErr

func (c *Context) WriteErr(w http.ResponseWriter, code int, err error)

WriteErr writes an error response to the http response

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse represents an API error to return to the caller

type Server

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

Server is an HTTP server configured with various magellan APIs

func NewServer

func NewServer(sc *servicesctrl.Control, conf cfg.Config) (*Server, error)

NewServer creates a new *Server based on the given config

func (*Server) Close

func (s *Server) Close() error

Close shuts the server down

func (*Server) Listen

func (s *Server) Listen() error

Listen begins listening for new socket connections and blocks until closed

type V2Context

type V2Context struct {
	*Context
	// contains filtered or unexported fields
}

func (*V2Context) ATxData

func (c *V2Context) ATxData(w web.ResponseWriter, r *web.Request)

func (*V2Context) AddressChains

func (c *V2Context) AddressChains(w web.ResponseWriter, r *web.Request)

func (*V2Context) AddressChainsPost

func (c *V2Context) AddressChainsPost(w web.ResponseWriter, r *web.Request)

func (*V2Context) Aggregate

func (c *V2Context) Aggregate(w web.ResponseWriter, r *web.Request)

func (*V2Context) CTxData

func (c *V2Context) CTxData(w web.ResponseWriter, r *web.Request)

func (*V2Context) CacheAddressCounts

func (c *V2Context) CacheAddressCounts(w web.ResponseWriter, r *web.Request)

func (*V2Context) CacheAggregates

func (c *V2Context) CacheAggregates(w web.ResponseWriter, r *web.Request)

func (*V2Context) CacheAssetAggregates

func (c *V2Context) CacheAssetAggregates(w web.ResponseWriter, r *web.Request)

func (*V2Context) CacheAssets

func (c *V2Context) CacheAssets(w web.ResponseWriter, r *web.Request)

func (*V2Context) CacheTxCounts

func (c *V2Context) CacheTxCounts(w web.ResponseWriter, r *web.Request)

func (*V2Context) GetAddress

func (c *V2Context) GetAddress(w web.ResponseWriter, r *web.Request)

func (*V2Context) GetAsset

func (c *V2Context) GetAsset(w web.ResponseWriter, r *web.Request)

func (*V2Context) GetBlock

func (c *V2Context) GetBlock(w web.ResponseWriter, r *web.Request)

func (*V2Context) GetOutput

func (c *V2Context) GetOutput(w web.ResponseWriter, r *web.Request)

func (*V2Context) GetTransaction

func (c *V2Context) GetTransaction(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListAddresses

func (c *V2Context) ListAddresses(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListAssets

func (c *V2Context) ListAssets(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListBlocks

func (c *V2Context) ListBlocks(w web.ResponseWriter, r *web.Request)

PVM

func (*V2Context) ListCBlocks

func (c *V2Context) ListCBlocks(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListCTransactions

func (c *V2Context) ListCTransactions(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListOutputs

func (c *V2Context) ListOutputs(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListTransactions

func (c *V2Context) ListTransactions(w web.ResponseWriter, r *web.Request)

func (*V2Context) ListTransactionsPost

func (c *V2Context) ListTransactionsPost(w web.ResponseWriter, r *web.Request)

func (*V2Context) PTxData

func (c *V2Context) PTxData(w web.ResponseWriter, r *web.Request)

func (*V2Context) Search

func (c *V2Context) Search(w web.ResponseWriter, r *web.Request)

func (*V2Context) TxfeeAggregate

func (c *V2Context) TxfeeAggregate(w web.ResponseWriter, r *web.Request)

Jump to

Keyboard shortcuts

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