facade

package
v1.0.96 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRestInterface = "localhost:8080"

DefaultRestInterface is the default interface the rest API will start on if not specified

View Source
const DefaultRestPortOff = "off"

DefaultRestPortOff is the default value that should be passed if it is desired

to start the node without a REST endpoint available

Variables

View Source
var ErrHeartbeatsNotActive = errors.New("heartbeat system not active")

ErrHeartbeatsNotActive signals that the heartbeat system is not active

View Source
var ErrInvalidValue = errors.New("invalid value")

ErrInvalidValue signals that an invalid value has been provided

View Source
var ErrNilApiResolver = errors.New("nil api resolver")

ErrNilApiResolver signals that a nil api resolver instance has been provided

View Source
var ErrNilNode = errors.New("nil node")

ErrNilNode signals that a nil node instance has been provided

Functions

This section is empty.

Types

type ApiResolver

type ApiResolver interface {
	ExecuteSCQuery(query *process.SCQuery) (*vmcommon.VMOutput, error)
	ComputeTransactionGasLimit(tx *transaction.Transaction) (uint64, error)
	StatusMetrics() external.StatusMetricsHandler
	IsInterfaceNil() bool
}

ApiResolver defines a structure capable of resolving REST API requests

type ElrondNodeFacade

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

ElrondNodeFacade represents a facade for grouping the functionality for node, transaction and address

func NewElrondNodeFacade

func NewElrondNodeFacade(
	node NodeWrapper,
	apiResolver ApiResolver,
	restAPIServerDebugMode bool,
	wsAntifloodConfig config.WebServerAntifloodConfig,
) (*ElrondNodeFacade, error)

NewElrondNodeFacade creates a new Facade with a NodeWrapper

func (*ElrondNodeFacade) ComputeTransactionGasLimit

func (ef *ElrondNodeFacade) ComputeTransactionGasLimit(tx *transaction.Transaction) (uint64, error)

ComputeTransactionGasLimit will estimate how many gas a transaction will consume

func (*ElrondNodeFacade) CreateTransaction

func (ef *ElrondNodeFacade) CreateTransaction(
	nonce uint64,
	value string,
	receiverHex string,
	senderHex string,
	gasPrice uint64,
	gasLimit uint64,
	txData []byte,
	signatureHex string,
) (*transaction.Transaction, []byte, error)

CreateTransaction creates a transaction from all needed fields

func (*ElrondNodeFacade) ExecuteSCQuery

func (ef *ElrondNodeFacade) ExecuteSCQuery(query *process.SCQuery) (*vmcommon.VMOutput, error)

ExecuteSCQuery retrieves data from existing SC trie

func (*ElrondNodeFacade) GetAccount

func (ef *ElrondNodeFacade) GetAccount(address string) (*state.Account, error)

GetAccount returns an accountResponse containing information about the account correlated with provided address

func (*ElrondNodeFacade) GetBalance

func (ef *ElrondNodeFacade) GetBalance(address string) (*big.Int, error)

GetBalance gets the current balance for a specified address

func (*ElrondNodeFacade) GetHeartbeats

func (ef *ElrondNodeFacade) GetHeartbeats() ([]heartbeat.PubKeyHeartbeat, error)

GetHeartbeats returns the heartbeat status for each public key from initial list or later joined to the network

func (*ElrondNodeFacade) GetTransaction

func (ef *ElrondNodeFacade) GetTransaction(hash string) (*transaction.Transaction, error)

GetTransaction gets the transaction with a specified hash

func (*ElrondNodeFacade) IsInterfaceNil

func (ef *ElrondNodeFacade) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*ElrondNodeFacade) IsNodeRunning

func (ef *ElrondNodeFacade) IsNodeRunning() bool

IsNodeRunning gets if the underlying node is running

func (*ElrondNodeFacade) PprofEnabled

func (ef *ElrondNodeFacade) PprofEnabled() bool

PprofEnabled returns if profiling mode should be active or not on the application

func (*ElrondNodeFacade) RestAPIServerDebugMode

func (ef *ElrondNodeFacade) RestAPIServerDebugMode() bool

RestAPIServerDebugMode return true is debug mode for Rest API is enabled

func (*ElrondNodeFacade) RestApiInterface

func (ef *ElrondNodeFacade) RestApiInterface() string

RestApiInterface returns the interface on which the rest API should start on, based on the config file provided. The API will start on the DefaultRestInterface value unless a correct value is passed or

the value is explicitly set to off, in which case it will not start at all

func (*ElrondNodeFacade) SendBulkTransactions

func (ef *ElrondNodeFacade) SendBulkTransactions(txs []*transaction.Transaction) (uint64, error)

SendBulkTransactions will send a bulk of transactions on the topic channel

func (*ElrondNodeFacade) SetConfig

func (ef *ElrondNodeFacade) SetConfig(facadeConfig *config.FacadeConfig)

SetConfig sets the configuration options for the facade TODO inject this on the constructor and add tests for bad config values

func (*ElrondNodeFacade) SetSyncer

func (ef *ElrondNodeFacade) SetSyncer(syncer ntp.SyncTimer)

SetSyncer sets the current syncer

func (*ElrondNodeFacade) SetTpsBenchmark

func (ef *ElrondNodeFacade) SetTpsBenchmark(tpsBenchmark *statistics.TpsBenchmark)

SetTpsBenchmark sets the tps benchmark handler

func (*ElrondNodeFacade) StartBackgroundServices

func (ef *ElrondNodeFacade) StartBackgroundServices()

StartBackgroundServices starts all background services needed for the correct functionality of the node

func (*ElrondNodeFacade) StartNode

func (ef *ElrondNodeFacade) StartNode() error

StartNode starts the underlying node

func (*ElrondNodeFacade) StatusMetrics

func (ef *ElrondNodeFacade) StatusMetrics() external.StatusMetricsHandler

StatusMetrics will return the node's status metrics

func (*ElrondNodeFacade) TpsBenchmark

func (ef *ElrondNodeFacade) TpsBenchmark() *statistics.TpsBenchmark

TpsBenchmark returns the tps benchmark handler

func (*ElrondNodeFacade) ValidatorStatisticsApi

func (ef *ElrondNodeFacade) ValidatorStatisticsApi() (map[string]*state.ValidatorApiResponse, error)

ValidatorStatisticsApi will return the statistics for all validators

type NodeWrapper

type NodeWrapper interface {
	// Start will create a new messenger and and set up the Node state as running
	Start() error

	// P2PBootstrap starts the peer discovery process and peer connection filtering
	P2PBootstrap() error

	//IsRunning returns if the underlying node is running
	IsRunning() bool

	// StartConsensus will start the consesus service for the current node
	StartConsensus() error

	//GetBalance returns the balance for a specific address
	GetBalance(address string) (*big.Int, error)

	//CreateTransaction will return a transaction from all needed fields
	CreateTransaction(nonce uint64, value string, receiverHex string, senderHex string, gasPrice uint64,
		gasLimit uint64, data []byte, signatureHex string) (*transaction.Transaction, []byte, error)

	//SendBulkTransactions will send a bulk of transactions on the 'send transactions pipe' channel
	SendBulkTransactions(txs []*transaction.Transaction) (uint64, error)

	//GetTransaction gets the transaction
	GetTransaction(hash string) (*transaction.Transaction, error)

	// GetAccount returns an accountResponse containing information
	//  about the account corelated with provided address
	GetAccount(address string) (*state.Account, error)

	// GetHeartbeats returns the heartbeat status for each public key defined in genesis.json
	GetHeartbeats() []heartbeat.PubKeyHeartbeat

	// IsInterfaceNil returns true if there is no value under the interface
	IsInterfaceNil() bool

	// ValidatorStatisticsApi return the statistics for all the validators
	ValidatorStatisticsApi() (map[string]*state.ValidatorApiResponse, error)
}

NodeWrapper contains all functions that a node should contain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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