facade

package
v1.1.30 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 30 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 ErrNilAccountState = errors.New("nil account state")

ErrNilAccountState signals that a nil account state 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

View Source
var ErrNilPeerState = errors.New("nil peer state")

ErrNilPeerState signals that a nil peer state has been provided

View Source
var ErrNilTransactionSimulatorProcessor = errors.New("nil transaction simulator processor")

ErrNilTransactionSimulatorProcessor signals that a nil transaction simulator processor has been provided

View Source
var ErrNoApiRoutesConfig = errors.New("no configuration found for API routes")

ErrNoApiRoutesConfig signals that no configuration was found for API routes

Functions

func NewNodeFacade added in v1.0.102

func NewNodeFacade(arg ArgNodeFacade) (*nodeFacade, error)

NewNodeFacade creates a new Facade with a NodeWrapper

Types

type ApiResolver

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

ApiResolver defines a structure capable of resolving REST API requests

type ArgNodeFacade added in v1.0.102

type ArgNodeFacade struct {
	Node                   NodeHandler
	ApiResolver            ApiResolver
	TxSimulatorProcessor   TransactionSimulatorProcessor
	RestAPIServerDebugMode bool
	WsAntifloodConfig      config.WebServerAntifloodConfig
	FacadeConfig           config.FacadeConfig
	ApiRoutesConfig        config.ApiRoutesConfig
	AccountsState          state.AccountsAdapter
	PeerState              state.AccountsAdapter
}

ArgNodeFacade represents the argument for the nodeFacade

type HardforkTrigger added in v1.0.102

type HardforkTrigger interface {
	Trigger(epoch uint32, withEarlyEndOfEpoch bool) error
	IsSelfTrigger() bool
	IsInterfaceNil() bool
}

HardforkTrigger defines the structure used to trigger hardforks

type NodeHandler added in v1.0.102

type NodeHandler interface {
	// 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)

	// GetUsername returns the username for a specific address
	GetUsername(address string) (string, error)

	// GetValueForKey returns the value of a key from a given account
	GetValueForKey(address string, key string) (string, error)

	// GetKeyValuePairs returns the key-value pairs under a given address
	GetKeyValuePairs(address string) (map[string]string, error)

	// GetESDTBalance returns the esdt balance and properties from a given account
	GetESDTBalance(address string, key string) (string, string, error)

	// GetAllESDTTokens returns the value of a key from a given account
	GetAllESDTTokens(address string) ([]string, error)

	//CreateTransaction will return a transaction from all needed fields
	CreateTransaction(nonce uint64, value string, receiver string, receiverUsername []byte, sender string, senderUsername []byte, gasPrice uint64,
		gasLimit uint64, data []byte, signatureHex string, chainID string, version uint32, options uint32) (*transaction.Transaction, []byte, error)

	//ValidateTransaction will validate a transaction
	ValidateTransaction(tx *transaction.Transaction) error
	ValidateTransactionForSimulation(tx *transaction.Transaction, checkSignature bool) error

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

	//GetTransaction will return a transaction based on the hash
	GetTransaction(hash string, withResults bool) (*transaction.ApiTransactionResult, error)

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

	// GetCode returns the code for the given account
	GetCode(account state.UserAccountHandler) []byte

	// GetHeartbeats returns the heartbeat status for each public key defined in genesis.json
	GetHeartbeats() []data.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)
	DirectTrigger(epoch uint32, withEarlyEndOfEpoch bool) error
	IsSelfTrigger() bool

	EncodeAddressPubkey(pk []byte) (string, error)
	DecodeAddressPubkey(pk string) ([]byte, error)

	GetQueryHandler(name string) (debug.QueryHandler, error)
	GetPeerInfo(pid string) ([]core.QueryP2PPeerInfo, error)

	GetBlockByHash(hash string, withTxs bool) (*api.Block, error)
	GetBlockByNonce(nonce uint64, withTxs bool) (*api.Block, error)
}

NodeHandler contains all functions that a node should contain.

type TransactionSimulatorProcessor added in v1.1.1

type TransactionSimulatorProcessor interface {
	ProcessTx(tx *transaction.Transaction) (*transaction.SimulationResults, error)
	IsInterfaceNil() bool
}

TransactionSimulatorProcessor defines the actions which a transaction simulator processor has to implement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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