facade

package
v1.3.48-hf04 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: GPL-3.0 Imports: 26 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 ErrEmptyGasConfigs = errors.New("empty gas configs")

ErrEmptyGasConfigs signals that the provided gas configs map is empty

View Source
var ErrEmptyRootHash = errors.New("empty current root hash")

ErrEmptyRootHash signals that the current root hash is empty

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 ErrNilBlockchain = errors.New("nil blockchain")

ErrNilBlockchain signals that a nil blockchain has been provided

View Source
var ErrNilGenesisBalances = errors.New("nil genesis balances slice")

ErrNilGenesisBalances signals that the provided genesis balances slice is nil

View Source
var ErrNilGenesisNodes = errors.New("nil genesis nodes")

ErrNilGenesisNodes signals that the provided genesis nodes configuration is nil

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) (*transaction.CostResponse, error)
	StatusMetrics() external.StatusMetricsHandler
	GetTotalStakedValue(ctx context.Context) (*api.StakeValues, error)
	GetDirectStakedList(ctx context.Context) ([]*api.DirectStakedValue, error)
	GetDelegatorsList(ctx context.Context) ([]*api.Delegator, error)
	GetTransaction(hash string, withResults bool) (*transaction.ApiTransactionResult, error)
	GetTransactionsPool(fields string) (*common.TransactionsPoolAPIResponse, error)
	GetTransactionsPoolForSender(sender, fields string) (*common.TransactionsPoolForSenderApiResponse, error)
	GetLastPoolNonceForSender(sender string) (uint64, error)
	GetTransactionsPoolNonceGapsForSender(sender string) (*common.TransactionsPoolNonceGapsForSenderApiResponse, error)
	GetBlockByHash(hash string, options api.BlockQueryOptions) (*api.Block, error)
	GetBlockByNonce(nonce uint64, options api.BlockQueryOptions) (*api.Block, error)
	GetBlockByRound(round uint64, options api.BlockQueryOptions) (*api.Block, error)
	GetInternalShardBlockByNonce(format common.ApiOutputFormat, nonce uint64) (interface{}, error)
	GetInternalShardBlockByHash(format common.ApiOutputFormat, hash string) (interface{}, error)
	GetInternalShardBlockByRound(format common.ApiOutputFormat, round uint64) (interface{}, error)
	GetInternalMetaBlockByNonce(format common.ApiOutputFormat, nonce uint64) (interface{}, error)
	GetInternalMetaBlockByHash(format common.ApiOutputFormat, hash string) (interface{}, error)
	GetInternalMetaBlockByRound(format common.ApiOutputFormat, round uint64) (interface{}, error)
	GetInternalStartOfEpochMetaBlock(format common.ApiOutputFormat, epoch uint32) (interface{}, error)
	GetInternalMiniBlock(format common.ApiOutputFormat, txHash string, epoch uint32) (interface{}, error)
	GetGenesisNodesPubKeys() (map[uint32][]string, map[uint32][]string)
	GetGenesisBalances() ([]*common.InitialAccountAPI, error)
	GetGasConfigs() map[string]map[string]uint64
	Close() 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
	Blockchain             chainData.ChainHandler
}

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 {
	// GetBalance returns the balance for a specific address
	GetBalance(address string, options api.AccountQueryOptions) (*big.Int, api.BlockInfo, error)

	// GetUsername returns the username for a specific address
	GetUsername(address string, options api.AccountQueryOptions) (string, api.BlockInfo, error)

	// GetValueForKey returns the value of a key from a given account
	GetValueForKey(address string, key string, options api.AccountQueryOptions) (string, api.BlockInfo, error)

	// GetKeyValuePairs returns the key-value pairs under a given address
	GetKeyValuePairs(address string, options api.AccountQueryOptions, ctx context.Context) (map[string]string, api.BlockInfo, error)

	// GetAllIssuedESDTs returns all the issued esdt tokens from esdt system smart contract
	GetAllIssuedESDTs(tokenType string, ctx context.Context) ([]string, error)

	// GetESDTData returns the esdt data from a given account, given key and given nonce
	GetESDTData(address, tokenID string, nonce uint64, options api.AccountQueryOptions) (*esdt.ESDigitalToken, api.BlockInfo, error)

	// GetESDTsRoles returns the the token identifiers and the roles for a given address
	GetESDTsRoles(address string, options api.AccountQueryOptions, ctx context.Context) (map[string][]string, api.BlockInfo, error)

	// GetNFTTokenIDsRegisteredByAddress returns all the token identifiers for semi or non fungible tokens registered by the address
	GetNFTTokenIDsRegisteredByAddress(address string, options api.AccountQueryOptions, ctx context.Context) ([]string, api.BlockInfo, error)

	// GetESDTsWithRole returns the token identifiers where the specified address has the given role
	GetESDTsWithRole(address string, role string, options api.AccountQueryOptions, ctx context.Context) ([]string, api.BlockInfo, error)

	// GetAllESDTTokens returns the value of a key from a given account
	GetAllESDTTokens(address string, options api.AccountQueryOptions, ctx context.Context) (map[string]*esdt.ESDigitalToken, api.BlockInfo, error)

	// GetTokenSupply returns the provided token supply from current shard
	GetTokenSupply(token string) (*api.ESDTSupply, 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)

	// GetAccount returns an accountResponse containing information
	//  about the account correlated with provided address
	GetAccount(address string, options api.AccountQueryOptions) (api.AccountResponse, api.BlockInfo, error)

	// GetCode returns the code for the given code hash
	GetCode(codeHash []byte, options api.AccountQueryOptions) ([]byte, api.BlockInfo)

	// 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)

	GetEpochStartDataAPI(epoch uint32) (*common.EpochStartDataAPI, error)

	GetProof(rootHash string, key string) (*common.GetProofResponse, error)
	GetProofDataTrie(rootHash string, address string, key string) (*common.GetProofResponse, *common.GetProofResponse, error)
	VerifyProof(rootHash string, address string, proof [][]byte) (bool, error)
}

NodeHandler contains all functions that a node should contain.

type TransactionSimulatorProcessor added in v1.1.1

type TransactionSimulatorProcessor interface {
	ProcessTx(tx *transaction.Transaction) (*txSimData.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