facade

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: GPL-3.0 Imports: 28 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 ErrNoApiRoutesConfig = errors.New("no configuration found for API routes")

ErrNoApiRoutesConfig signals that no configuration was found for API routes

Functions

func NewNodeFacade

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
	IsInterfaceNil() bool
}

ApiResolver defines a structure capable of resolving REST API requests

type ArgNodeFacade

type ArgNodeFacade struct {
	Node                   NodeHandler
	ApiResolver            ApiResolver
	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

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

HardforkTrigger defines the structure used to trigger hardforks

type NodeHandler

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)

	// GetValueForKey returns the value of a key from a given account
	GetValueForKey(address string, key string) (string, 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, chainID string, version uint32) (*transaction.Transaction, []byte, error)

	//ValidateTransaction will validate a transaction
	ValidateTransaction(tx *transaction.Transaction) 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) (*transaction.ApiTransactionResult, error)

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

	// 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) 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) (*block.APIBlock, error)
	GetBlockByNonce(nonce uint64, withTxs bool) (*block.APIBlock, error)
}

NodeHandler 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