facade

package
v1.0.38 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRestPort = "8080"

DefaultRestPort is the default port 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

Functions

This section is empty.

Types

type ApiResolver

type ApiResolver interface {
	GetVmValue(address string, funcName string, argsBuff ...[]byte) ([]byte, 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) *ElrondNodeFacade

NewElrondNodeFacade creates a new Facade with a NodeWrapper

func (*ElrondNodeFacade) CreateTransaction

func (ef *ElrondNodeFacade) CreateTransaction(
	nonce uint64,
	value *big.Int,
	receiverHex string,
	senderHex string,
	gasPrice uint64,
	gasLimit uint64,
	data string,
	signatureHex string,
	challenge string,
) (*transaction.Transaction, error)

CreateTransaction creates a transaction from all needed fields

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) GetCurrentPublicKey added in v1.0.3

func (ef *ElrondNodeFacade) GetCurrentPublicKey() string

GetCurrentPublicKey gets the current nodes public Key

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) GetVmValue added in v1.0.11

func (ef *ElrondNodeFacade) GetVmValue(address string, funcName string, argsBuff ...[]byte) ([]byte, error)

GetVmValue retrieves data from existing SC trie

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) PrometheusJoinURL added in v1.0.11

func (ef *ElrondNodeFacade) PrometheusJoinURL() string

PrometheusJoinURL will return the join URL from server.toml

func (*ElrondNodeFacade) PrometheusMonitoring added in v1.0.11

func (ef *ElrondNodeFacade) PrometheusMonitoring() bool

PrometheusMonitoring returns if prometheus is enabled for monitoring by the flag

func (*ElrondNodeFacade) PrometheusNetworkID added in v1.0.11

func (ef *ElrondNodeFacade) PrometheusNetworkID() string

PrometheusNetworkID will return the NetworkID from config.toml or the flag

func (*ElrondNodeFacade) RestAPIServerDebugMode

func (ef *ElrondNodeFacade) RestAPIServerDebugMode() bool

RestAPIServerDebugMode return true is debug mode for Rest API is enabled

func (*ElrondNodeFacade) RestApiPort added in v1.0.3

func (ef *ElrondNodeFacade) RestApiPort() string

RestApiPort returns the port on which the api should start on, based on the config file provided. The API will start on the DefaultRestPort 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) SendTransaction added in v1.0.3

func (ef *ElrondNodeFacade) SendTransaction(
	nonce uint64,
	senderHex string,
	receiverHex string,
	value *big.Int,
	gasPrice uint64,
	gasLimit uint64,
	transactionData string,
	signature []byte,
) (string, error)

SendTransaction will send a new transaction on the topic channel

func (*ElrondNodeFacade) SetConfig

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

SetConfig sets the configuration options for the facade

func (*ElrondNodeFacade) SetLogger added in v1.0.3

func (ef *ElrondNodeFacade) SetLogger(log *logger.Logger)

SetLogger sets the current logger

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(wg *sync.WaitGroup)

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) StopNode added in v1.0.3

func (ef *ElrondNodeFacade) StopNode() error

StopNode stops the underlying node

func (*ElrondNodeFacade) TpsBenchmark

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

TpsBenchmark returns the tps benchmark handler

type NodeWrapper

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

	// Stop closes the messenger and undos everything done in Start
	Stop() 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)

	//GenerateTransaction generates a new transaction with sender, receiver, amount and code
	GenerateTransaction(senderHex string, receiverHex string, amount *big.Int, code string) (*transaction.Transaction, error)

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

	//SendTransaction will send a new transaction on the 'send transactions pipe' channel
	SendTransaction(nonce uint64, senderHex string, receiverHex string, value *big.Int, gasPrice uint64, gasLimit uint64, transactionData string, signature []byte) (string, 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)

	// GetCurrentPublicKey gets the current nodes public Key
	GetCurrentPublicKey() string

	// GenerateAndSendBulkTransactions generates a number of nrTransactions of amount value
	//  for the receiver destination
	GenerateAndSendBulkTransactions(string, *big.Int, uint64) error

	// GenerateAndSendBulkTransactionsOneByOne generates a number of nrTransactions of amount value
	//  for the receiver destination in a one-by-one fashion
	GenerateAndSendBulkTransactionsOneByOne(string, *big.Int, uint64) 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
}

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