grpcserver

package
v0.1.15-a Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServerOptions = []grpc.ServerOption{

	grpc.KeepaliveParams(keepalive.ServerParameters{
		MaxConnectionIdle:     time.Minute * 120,
		MaxConnectionAge:      time.Minute * 180,
		MaxConnectionAgeGrace: time.Minute * 10,
		Time:                  time.Minute,
		Timeout:               time.Minute * 3,
	}),
}

ServerOptions are shared by all grpc servers

Functions

This section is empty.

Types

type GlobalStateService

type GlobalStateService struct {
	Network     api.NetworkAPI // P2P Swarm
	Mesh        api.TxAPI      // Mesh
	GenTime     api.GenesisTimeAPI
	PeerCounter api.PeerCounter
	Syncer      api.Syncer
}

GlobalStateService exposes global state data, output from the STF

func NewGlobalStateService

func NewGlobalStateService(
	net api.NetworkAPI, tx api.TxAPI, genTime api.GenesisTimeAPI,
	syncer api.Syncer) *GlobalStateService

NewGlobalStateService creates a new grpc service using config data.

func (GlobalStateService) Account

Account returns counter and balance for one account

func (GlobalStateService) AccountDataQuery

AccountDataQuery returns historical account data such as rewards and receipts

func (GlobalStateService) AccountDataStream

AccountDataStream exposes a stream of account-related data

func (GlobalStateService) AppEventStream

AppEventStream exposes a stream of emitted app events

func (GlobalStateService) GlobalStateHash

GlobalStateHash returns the latest layer and its computed global state hash

func (GlobalStateService) GlobalStateStream

GlobalStateStream exposes a stream of global data data items: rewards, receipts, account info, global state hash

func (GlobalStateService) RegisterService

func (s GlobalStateService) RegisterService(server *Server)

RegisterService registers this service with a grpc server instance

func (GlobalStateService) SmesherDataQuery

SmesherDataQuery returns historical info on smesher rewards

func (GlobalStateService) SmesherRewardStream

SmesherRewardStream exposes a stream of smesher rewards

type JSONHTTPServer

type JSONHTTPServer struct {
	Port     int
	GrpcPort int
	// contains filtered or unexported fields
}

JSONHTTPServer is a JSON http server providing the Spacemesh API. It is implemented using a grpc-gateway. See https://github.com/grpc-ecosystem/grpc-gateway .

func NewJSONHTTPServer

func NewJSONHTTPServer(port int, grpcPort int) *JSONHTTPServer

NewJSONHTTPServer creates a new json http server.

func (*JSONHTTPServer) Close

func (s *JSONHTTPServer) Close() error

Close stops the server.

func (*JSONHTTPServer) StartService

func (s *JSONHTTPServer) StartService(startNodeService bool, startMeshService bool,
	startGlobalStateService bool, startSmesherService bool, startTransactionService bool)

StartService starts the json api server and listens for status (started, stopped).

type MeshService

type MeshService struct {
	Mesh             api.TxAPI // Mesh
	Mempool          *state.TxMempool
	GenTime          api.GenesisTimeAPI
	LayersPerEpoch   int
	NetworkID        int8
	LayerDurationSec int
	LayerAvgSize     int
	TxsPerBlock      int
}

MeshService exposes mesh data such as accounts, blocks, and transactions

func NewMeshService

func NewMeshService(
	tx api.TxAPI, mempool *state.TxMempool, genTime api.GenesisTimeAPI,
	layersPerEpoch int, networkID int8, layerDurationSec int,
	layerAvgSize int, txsPerBlock int) *MeshService

NewMeshService creates a new service using config data

func (MeshService) AccountMeshDataQuery

AccountMeshDataQuery returns account data

func (MeshService) AccountMeshDataStream

AccountMeshDataStream exposes a stream of transactions and activations for an account

func (MeshService) CurrentEpoch

CurrentEpoch returns the current epoch number

func (MeshService) CurrentLayer

CurrentLayer returns the current layer number

func (MeshService) EpochNumLayers

EpochNumLayers returns the number of layers per epoch (a network parameter)

func (MeshService) GenesisTime

GenesisTime returns the network genesis time as UNIX time

func (MeshService) LayerDuration

LayerDuration returns the layer duration in seconds (a network parameter)

func (MeshService) LayerStream

LayerStream exposes a stream of all mesh data per layer

func (MeshService) LayersQuery

LayersQuery returns all mesh data, layer by layer

func (MeshService) MaxTransactionsPerSecond

MaxTransactionsPerSecond returns the max number of tx per sec (a network parameter)

func (MeshService) NetID

NetID returns the network ID

func (MeshService) RegisterService

func (s MeshService) RegisterService(server *Server)

RegisterService registers this service with a grpc server instance

type NodeService

type NodeService struct {
	Mesh        api.TxAPI
	GenTime     api.GenesisTimeAPI
	PeerCounter api.PeerCounter
	Syncer      api.Syncer
}

NodeService is a grpc server that provides the NodeService, which exposes node-related data such as node status, software version, errors, etc. It can also be used to start the sync process, or to shut down the node.

func NewNodeService

func NewNodeService(
	net api.NetworkAPI, tx api.TxAPI, genTime api.GenesisTimeAPI, syncer api.Syncer) *NodeService

NewNodeService creates a new grpc service using config data.

func (NodeService) Build

func (s NodeService) Build(ctx context.Context, in *empty.Empty) (*pb.BuildResponse, error)

Build returns the build of the node software

func (NodeService) Echo

Echo returns the response for an echo api request. It's used for E2E tests.

func (NodeService) ErrorStream

func (s NodeService) ErrorStream(request *pb.ErrorStreamRequest, stream pb.NodeService_ErrorStreamServer) error

ErrorStream exposes a stream of node errors

func (NodeService) RegisterService

func (s NodeService) RegisterService(server *Server)

RegisterService registers this service with a grpc server instance

func (NodeService) Shutdown

func (s NodeService) Shutdown(ctx context.Context, request *pb.ShutdownRequest) (*pb.ShutdownResponse, error)

Shutdown requests a graceful shutdown

func (NodeService) Status

func (s NodeService) Status(ctx context.Context, request *pb.StatusRequest) (*pb.StatusResponse, error)

Status returns a status object providing information about the connected peers, sync status, current and verified layer

func (NodeService) StatusStream

func (s NodeService) StatusStream(request *pb.StatusStreamRequest, stream pb.NodeService_StatusStreamServer) error

StatusStream exposes a stream of node status updates

func (NodeService) SyncStart

func (s NodeService) SyncStart(ctx context.Context, request *pb.SyncStartRequest) (*pb.SyncStartResponse, error)

SyncStart requests that the node start syncing the mesh (if it isn't already syncing)

func (NodeService) Version

func (s NodeService) Version(ctx context.Context, in *empty.Empty) (*pb.VersionResponse, error)

Version returns the version of the node software as a semver string

type Server

type Server struct {
	Port       int
	Interface  string
	GrpcServer *grpc.Server
}

Server is a very basic grpc server

func NewServerWithInterface

func NewServerWithInterface(port int, intfce string) *Server

NewServerWithInterface creates and returns a new Server with port and interface

func (*Server) Close

func (s *Server) Close()

Close stops the server

func (*Server) Start

func (s *Server) Start()

Start starts the server

type ServiceAPI

type ServiceAPI interface {
	RegisterService(*Server)
}

ServiceAPI allows individual grpc services to register the grpc server

type SmesherService

type SmesherService struct {
	Mining api.MiningAPI
}

SmesherService exposes endpoints to manage smeshing

func NewSmesherService

func NewSmesherService(miner api.MiningAPI) *SmesherService

NewSmesherService creates a new grpc service using config data.

func (SmesherService) Coinbase

func (s SmesherService) Coinbase(ctx context.Context, in *empty.Empty) (*pb.CoinbaseResponse, error)

Coinbase returns the current coinbase setting of this node

func (SmesherService) CreatePostData

CreatePostData requests that the node begin post init

func (SmesherService) IsSmeshing

func (s SmesherService) IsSmeshing(ctx context.Context, in *empty.Empty) (*pb.IsSmeshingResponse, error)

IsSmeshing reports whether the node is smeshing

func (SmesherService) MinGas

MinGas returns the current mingas setting of this node

func (SmesherService) PostComputeProviders

func (s SmesherService) PostComputeProviders(ctx context.Context, in *empty.Empty) (*pb.PostComputeProvidersResponse, error)

PostComputeProviders returns a list of available post compute providers

func (SmesherService) PostDataCreationProgressStream

func (s SmesherService) PostDataCreationProgressStream(request *empty.Empty, stream pb.SmesherService_PostDataCreationProgressStreamServer) error

PostDataCreationProgressStream exposes a stream of updates during post init

func (SmesherService) PostStatus

func (s SmesherService) PostStatus(ctx context.Context, in *empty.Empty) (*pb.PostStatusResponse, error)

PostStatus returns post data status

func (SmesherService) RegisterService

func (s SmesherService) RegisterService(server *Server)

RegisterService registers this service with a grpc server instance

func (SmesherService) SetCoinbase

SetCoinbase sets the current coinbase setting of this node

func (SmesherService) SetMinGas

SetMinGas sets the mingas setting of this node

func (SmesherService) SmesherID

func (s SmesherService) SmesherID(ctx context.Context, in *empty.Empty) (*pb.SmesherIDResponse, error)

SmesherID returns the smesher ID of this node

func (SmesherService) StartSmeshing

StartSmeshing requests that the node begin smeshing

func (SmesherService) StopPostDataCreationSession

StopPostDataCreationSession requests that the node stop ongoing post data creation

func (SmesherService) StopSmeshing

StopSmeshing requests that the node stop smeshing

type TransactionService

type TransactionService struct {
	Network api.NetworkAPI // P2P Swarm
	Mesh    api.TxAPI      // Mesh
	Mempool *state.TxMempool
}

TransactionService exposes transaction data, and a submit tx endpoint

func NewTransactionService

func NewTransactionService(
	net api.NetworkAPI, tx api.TxAPI, mempool *state.TxMempool) *TransactionService

NewTransactionService creates a new grpc service using config data.

func (TransactionService) RegisterService

func (s TransactionService) RegisterService(server *Server)

RegisterService registers this service with a grpc server instance

func (TransactionService) SubmitTransaction

SubmitTransaction allows a new tx to be submitted

func (TransactionService) TransactionsState

TransactionsState returns current tx data for one or more txs

func (TransactionService) TransactionsStateStream

TransactionsStateStream exposes a stream of tx data

Jump to

Keyboard shortcuts

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