service

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package service implements an optional HTTP service that expose internal operation.

Index

Constants

View Source
const MAXBLOCKS = 50

MAXBLOCKS is the maximum number of blocks returned by the /blocks/ endpoint

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Service is the object that serves the HTTP Service API.

func NewService

func NewService(bindAddress string, n *node.Node, logger *logrus.Entry) *Service

NewService instantiates a Service linked to a Babble node and a bind address.

func (*Service) GetAllValidatorSets added in v0.5.4

func (s *Service) GetAllValidatorSets(w http.ResponseWriter, r *http.Request)

GetAllValidatorSets returns the entire map of round to validator-sets which represents the history of the validator-set from the inception of the network.

Get /history
returns: JSON map[int][]peers.Peer

func (*Service) GetBlock

func (s *Service) GetBlock(w http.ResponseWriter, r *http.Request)

GetBlock returns a single Block by block index.

func (*Service) GetBlocks added in v0.5.4

func (s *Service) GetBlocks(w http.ResponseWriter, r *http.Request)

GetBlocks will fetch an array of blocks starting at {startIndex} and finishing {counts<=MAXBLOCKS} blocks later. If no count param is provided it will just return the index requested rather than listing blocks.

GET /blocks/{startIndex}?count={x}
example: /blocks/0?count=50
returns: JSON []hashgraph.Block

func (*Service) GetGenesisPeers added in v0.5.0

func (s *Service) GetGenesisPeers(w http.ResponseWriter, r *http.Request)

GetGenesisPeers returns the genesis validator-set

Get /genesispeers
returns: JSON []peers.Peer

func (*Service) GetGraph added in v0.4.1

func (s *Service) GetGraph(w http.ResponseWriter, r *http.Request)

GetGraph returns information about the underlying hashgraph, which can be used to produce a visual representation.

func (*Service) GetPeers added in v0.4.1

func (s *Service) GetPeers(w http.ResponseWriter, r *http.Request)

GetPeers returns the node's current peers, which is not necessarily equivalent to the current validator-set.

GET /peers
returns: JSON []peers.Peer

func (*Service) GetStats

func (s *Service) GetStats(w http.ResponseWriter, r *http.Request)

GetStats returns a list of stats about the node's internal state.

func (*Service) GetValidatorSet added in v0.5.4

func (s *Service) GetValidatorSet(w http.ResponseWriter, r *http.Request)

GetValidatorSet returns the validator-set associated to a specific hashgraph round. If no round is specified, it returns the current validator-set.

Get /validators/{round}
returns: JSON []peers.Peer

func (*Service) Serve

func (s *Service) Serve()

Serve calls ListenAndServe. This is a blocking call. It is not necessary to call Serve when Babble is used in-memory and another server has already been started with the DefaultServerMux and the same address:port combination. Indeed, the service constructor has already registered the API handlers with DefaultServerMux.

Jump to

Keyboard shortcuts

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