node

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: GPL-3.0 Imports: 100 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// SoftRestartMessage is the custom message used when the node does a soft restart operation
	SoftRestartMessage = "Shuffled out - soft restart"
)

Variables

View Source
var ErrCannotCastAccountHandlerToUserAccountHandler = errors.New("cannot cast account handler to user account handler")

ErrCannotCastAccountHandlerToUserAccountHandler signals that an account handler cannot be cast to user account handler

View Source
var ErrCannotCastUserAccountHandlerToVmCommonUserAccountHandler = errors.New("cannot cast user account handler to vm common user account handler")

ErrCannotCastUserAccountHandlerToVmCommonUserAccountHandler signals that an user account handler cannot be cast to vm common user account handler

View Source
var ErrDataFieldTooBig = errors.New("data field is too big")

ErrDataFieldTooBig signals that the data field is too big

View Source
var ErrDifferentSenderShardId = errors.New("different shard ID between the transaction sender shard ID and current node shard ID")

ErrDifferentSenderShardId signals that a different shard ID was detected between the sender shard ID and the current node shard ID

View Source
var ErrEmptyQueryHandlerName = errors.New("empty query handler name")

ErrEmptyQueryHandlerName signals that an empty string can not be used to be used in the query handler container

View Source
var ErrInvalidAddressLength = errors.New("invalid address length")

ErrInvalidAddressLength signals that an invalid address length has been provided

View Source
var ErrInvalidChainIDInTransaction = errors.New("invalid chain ID")

ErrInvalidChainIDInTransaction signals that an invalid chain id has been provided in transaction

View Source
var ErrInvalidESDTRole = errors.New("invalid ESDT role")

ErrInvalidESDTRole signals that an invalid ESDT role has been provided

View Source
var ErrInvalidReceiverUsernameLength = errors.New("invalid receiver username length")

ErrInvalidReceiverUsernameLength signals that the length of the receiver username is invalid

View Source
var ErrInvalidSenderUsernameLength = errors.New("invalid sender username length")

ErrInvalidSenderUsernameLength signals that the length of the sender username is invalid

View Source
var ErrInvalidSignatureLength = errors.New("invalid signature length")

ErrInvalidSignatureLength signals that an invalid signature length has been provided

View Source
var ErrInvalidTransactionVersion = errors.New("invalid transaction version")

ErrInvalidTransactionVersion signals that an invalid transaction version has been provided

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

ErrInvalidValue signals that an invalid value has been provided such as NaN to an integer field

View Source
var ErrMetachainOnlyEndpoint = errors.New("the endpoint is only available on metachain nodes")

ErrMetachainOnlyEndpoint signals that an endpoint was called, but it is only available for metachain nodes

View Source
var ErrNegativeOrZeroConsensusGroupSize = errors.New("group size should be a strict positive number")

ErrNegativeOrZeroConsensusGroupSize signals that 0 elements consensus group is not supported

View Source
var ErrNilAccountsAdapter = errors.New("trying to set nil accounts adapter")

ErrNilAccountsAdapter signals that a nil accounts adapter has been provided

View Source
var ErrNilBootstrapComponents = errors.New("nil bootstrap componennts")

ErrNilBootstrapComponents signals that a nil bootstrap components instance has been provided

View Source
var ErrNilCoreComponents = errors.New("nil core components")

ErrNilCoreComponents signals that a nil core components instance has been provided

View Source
var ErrNilCreateTransactionArgs = errors.New("nil args for create transaction")

ErrNilCreateTransactionArgs signals that create transaction args is nil

View Source
var ErrNilCryptoComponents = errors.New("nil crypto components")

ErrNilCryptoComponents signals that a nil crypto components instance has been provided

View Source
var ErrNilDataComponents = errors.New("nil data components")

ErrNilDataComponents signals that a nil data components instance has been provided

View Source
var ErrNilDataPool = errors.New("trying to set nil data pool")

ErrNilDataPool signals that a nil data pool has been provided

View Source
var ErrNilESDTNFTStorageHandler = errors.New("nil esdt and nft storage handler")

ErrNilESDTNFTStorageHandler signals that a nil esdt and nft storage handler has been provided

View Source
var ErrNilMarshalizer = errors.New("trying to set nil marshalizer")

ErrNilMarshalizer signals that a nil marshalizer has been provided

View Source
var ErrNilNetworkComponents = errors.New("nil network components")

ErrNilNetworkComponents signals that a nil network components instance has been provided

View Source
var ErrNilNodeStopChannel = errors.New("nil node stop channel")

ErrNilNodeStopChannel signals that a nil channel for node process stop has been provided

View Source
var ErrNilPeerDenialEvaluator = errors.New("nil peer denial evaluator")

ErrNilPeerDenialEvaluator signals that a nil peer denial evaluator was provided

View Source
var ErrNilPrivateKey = errors.New("trying to set nil private key")

ErrNilPrivateKey signals that a nil private key has been provided

View Source
var ErrNilProcessComponents = errors.New("nil process components")

ErrNilProcessComponents signals that a nil process components instance has been provided

View Source
var ErrNilPubkeyConverter = errors.New("trying to use a nil pubkey converter")

ErrNilPubkeyConverter signals that a nil public key converter has been provided

View Source
var ErrNilQueryHandler = errors.New("nil query handler")

ErrNilQueryHandler signals that a nil query handler has been provided

View Source
var ErrNilRequestedItemsHandler = errors.New("nil requested items handler")

ErrNilRequestedItemsHandler signals that a nil requested items handler was provided

View Source
var ErrNilShardCoordinator = errors.New("trying to set nil shard coordinator")

ErrNilShardCoordinator signals that a nil shard coordinator has been provided

View Source
var ErrNilSingleSig = errors.New("trying to set nil singlesig")

ErrNilSingleSig signals that a nil singlesig object has been provided

View Source
var ErrNilStateComponents = errors.New("nil state components")

ErrNilStateComponents signals that a nil state components instance has been provided

View Source
var ErrNilStatusComponents = errors.New("nil status components")

ErrNilStatusComponents signals that a nil status components instance has been provided

View Source
var ErrNilStatusCoreComponents = errors.New("nil status core components")

ErrNilStatusCoreComponents signals that a nil status core components has been provided

View Source
var ErrNilStatusHandler = errors.New("nil status handler")

ErrNilStatusHandler signals that a nil status handler was provided

View Source
var ErrNodeCloseFailed = errors.New("node closing failed ")

ErrNodeCloseFailed signals that the close function of the node failed

View Source
var ErrQueryHandlerAlreadyExists = errors.New("query handler already exists")

ErrQueryHandlerAlreadyExists signals that the query handler is already registered

View Source
var ErrSystemBusyGeneratingTransactions = errors.New("system busy while generating bulk transactions")

ErrSystemBusyGeneratingTransactions signals that to many transactions are trying to get generated

View Source
var ErrTransactionValueLengthTooBig = errors.New("value length is too big")

ErrTransactionValueLengthTooBig signals that a too big value has been given to a transaction

View Source
var ErrTrieOperationsTimeout = errors.New("trie operations timeout")

ErrTrieOperationsTimeout signals that a trie operation took too long

View Source
var ErrUnknownPeerID = errors.New("unknown peer ID")

ErrUnknownPeerID signals that the provided peer is unknown by the current node

View Source
var ErrZeroRoundDurationNotSupported = errors.New("0 round duration time is not supported")

ErrZeroRoundDurationNotSupported signals that 0 seconds round duration is not supported

Functions

func NewNodeRunner

func NewNodeRunner(cfgs *config.Configs) (*nodeRunner, error)

NewNodeRunner creates a nodeRunner instance

Types

type HardforkTrigger

type HardforkTrigger interface {
	SetExportFactoryHandler(exportFactoryHandler update.ExportFactoryHandler) error
	TriggerReceived(payload []byte, data []byte, pkBytes []byte) (bool, error)
	RecordedTriggerMessage() ([]byte, bool)
	Trigger(epoch uint32, withEarlyEndOfEpoch bool) error
	CreateData() []byte
	AddCloser(closer update.Closer) error
	NotifyTriggerReceivedV2() <-chan struct{}
	IsSelfTrigger() bool
	IsInterfaceNil() bool
}

HardforkTrigger defines the behavior of a hardfork trigger

type HealthService

type HealthService interface {
	io.Closer
	RegisterComponent(component interface{})
}

HealthService defines the behavior of a service able to keep track of the node's health

type NetworkShardingCollector

type NetworkShardingCollector interface {
	UpdatePeerIDInfo(pid core.PeerID, pk []byte, shardID uint32)
	PutPeerIdSubType(pid core.PeerID, peerSubType core.P2PPeerSubType)
	GetPeerInfo(pid core.PeerID) core.P2PPeerInfo
	IsInterfaceNil() bool
}

NetworkShardingCollector defines the updating methods used by the network sharding component The interface assures that the collected data will be used by the p2p network sharding components

type Node

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

Node is a structure that holds all managed components

func CreateNode

func CreateNode(
	config *config.Config,
	statusCoreComponents factory.StatusCoreComponentsHandler,
	bootstrapComponents factory.BootstrapComponentsHandler,
	coreComponents factory.CoreComponentsHandler,
	cryptoComponents factory.CryptoComponentsHandler,
	dataComponents factory.DataComponentsHandler,
	networkComponents factory.NetworkComponentsHandler,
	processComponents factory.ProcessComponentsHandler,
	stateComponents factory.StateComponentsHandler,
	statusComponents factory.StatusComponentsHandler,
	heartbeatV2Components factory.HeartbeatV2ComponentsHandler,
	consensusComponents factory.ConsensusComponentsHandler,
	bootstrapRoundIndex uint64,
	isInImportMode bool,
) (*Node, error)

CreateNode is the node factory

func NewNode

func NewNode(opts ...Option) (*Node, error)

NewNode creates a new Node instance

func (*Node) AddQueryHandler

func (n *Node) AddQueryHandler(name string, handler debug.QueryHandler) error

AddQueryHandler adds a query handler in cache

func (*Node) ApplyOptions

func (n *Node) ApplyOptions(opts ...Option) error

ApplyOptions can set up different configurable options of a Node instance

func (*Node) Close

func (n *Node) Close() error

Close closes all underlying components

func (*Node) CreateShardedStores

func (n *Node) CreateShardedStores() error

CreateShardedStores instantiate sharded cachers for Transactions and Headers

func (*Node) CreateTransaction

func (n *Node) CreateTransaction(txArgs *external.ArgsCreateTransaction) (*transaction.Transaction, []byte, error)

CreateTransaction will return a transaction from all the required fields

func (*Node) DecodeAddressPubkey

func (n *Node) DecodeAddressPubkey(pk string) ([]byte, error)

DecodeAddressPubkey will try to decode the provided address public key string

func (*Node) DirectTrigger

func (n *Node) DirectTrigger(epoch uint32, withEarlyEndOfEpoch bool) error

DirectTrigger will start the hardfork trigger

func (*Node) EncodeAddressPubkey

func (n *Node) EncodeAddressPubkey(pk []byte) (string, error)

EncodeAddressPubkey will encode the provided address public key bytes to string

func (*Node) GenerateAndSendBulkTransactions

func (n *Node) GenerateAndSendBulkTransactions(
	receiverHex string,
	value *big.Int,
	numOfTxs uint64,
	sk crypto.PrivateKey,
	whiteList func([]*transaction.Transaction),
	chainID []byte,
	minTxVersion uint32,
) error

GenerateAndSendBulkTransactions is a method for generating and propagating a set of transactions to be processed. It is mainly used for demo purposes

func (*Node) GenerateTransaction

func (n *Node) GenerateTransaction(senderHex string, receiverHex string, value *big.Int, transactionData string, privateKey crypto.PrivateKey, chainID []byte, minTxVersion uint32) (*transaction.Transaction, error)

GenerateTransaction generates a new transaction with sender, receiver, amount and code

func (*Node) GetAccount

func (n *Node) GetAccount(address string, options api.AccountQueryOptions) (api.AccountResponse, api.BlockInfo, error)

GetAccount will return account details for a given address

func (*Node) GetAllESDTTokens

func (n *Node) GetAllESDTTokens(address string, options api.AccountQueryOptions, ctx context.Context) (map[string]*esdt.ESDigitalToken, api.BlockInfo, error)

GetAllESDTTokens returns all the ESDTs that the given address interacted with

func (*Node) GetAllIssuedESDTs

func (n *Node) GetAllIssuedESDTs(tokenType string, ctx context.Context) ([]string, error)

GetAllIssuedESDTs returns all the issued esdt tokens, works only on metachain

func (*Node) GetBalance

func (n *Node) GetBalance(address string, options api.AccountQueryOptions) (*big.Int, api.BlockInfo, error)

GetBalance gets the balance for a specific address

func (*Node) GetBootstrapComponents

func (n *Node) GetBootstrapComponents() mainFactory.BootstrapComponentsHolder

GetBootstrapComponents returns the bootstrap components

func (*Node) GetCode

func (n *Node) GetCode(codeHash []byte, options api.AccountQueryOptions) ([]byte, api.BlockInfo)

GetCode returns the code for the given code hash

func (*Node) GetCodeHash

func (n *Node) GetCodeHash(address string, options api.AccountQueryOptions) ([]byte, api.BlockInfo, error)

GetCodeHash gets the code hash for a specific address

func (*Node) GetConnectedPeersRatingsOnMainNetwork added in v1.6.0

func (n *Node) GetConnectedPeersRatingsOnMainNetwork() (string, error)

GetConnectedPeersRatingsOnMainNetwork returns the connected peers ratings on the main network

func (*Node) GetConsensusComponents

func (n *Node) GetConsensusComponents() mainFactory.ConsensusComponentsHolder

GetConsensusComponents returns the consensus components

func (*Node) GetConsensusGroupSize

func (n *Node) GetConsensusGroupSize() int

GetConsensusGroupSize returns the configured consensus size

func (*Node) GetCoreComponents

func (n *Node) GetCoreComponents() mainFactory.CoreComponentsHolder

GetCoreComponents returns the core components

func (*Node) GetCryptoComponents

func (n *Node) GetCryptoComponents() mainFactory.CryptoComponentsHolder

GetCryptoComponents returns the crypto components

func (*Node) GetDataComponents

func (n *Node) GetDataComponents() mainFactory.DataComponentsHolder

GetDataComponents returns the data components

func (*Node) GetESDTData

func (n *Node) GetESDTData(address, tokenID string, nonce uint64, options api.AccountQueryOptions) (*esdt.ESDigitalToken, api.BlockInfo, error)

GetESDTData returns the esdt balance and properties from a given account

func (*Node) GetESDTsRoles

func (n *Node) GetESDTsRoles(address string, options api.AccountQueryOptions, ctx context.Context) (map[string][]string, api.BlockInfo, error)

GetESDTsRoles returns all the tokens identifiers and roles for the given address

func (*Node) GetESDTsWithRole

func (n *Node) GetESDTsWithRole(address string, role string, options api.AccountQueryOptions, ctx context.Context) ([]string, api.BlockInfo, error)

GetESDTsWithRole returns all the tokens with the given role for the given address

func (*Node) GetEpochStartDataAPI

func (n *Node) GetEpochStartDataAPI(epoch uint32) (*common.EpochStartDataAPI, error)

GetEpochStartDataAPI returns epoch start data of a given epoch

func (*Node) GetGuardianData added in v1.5.0

func (n *Node) GetGuardianData(address string, options api.AccountQueryOptions) (api.GuardianData, api.BlockInfo, error)

GetGuardianData returns the guardian data for given account

func (*Node) GetHeartbeatV2Components

func (n *Node) GetHeartbeatV2Components() mainFactory.HeartbeatV2ComponentsHolder

GetHeartbeatV2Components returns the heartbeatV2 components

func (*Node) GetHeartbeats

func (n *Node) GetHeartbeats() []heartbeatData.PubKeyHeartbeat

GetHeartbeats returns the heartbeat status for each public key defined in genesis.json

func (*Node) GetKeyValuePairs

func (n *Node) GetKeyValuePairs(address string, options api.AccountQueryOptions, ctx context.Context) (map[string]string, api.BlockInfo, error)

GetKeyValuePairs returns all the key-value pairs under the address

func (*Node) GetNFTTokenIDsRegisteredByAddress

func (n *Node) GetNFTTokenIDsRegisteredByAddress(address string, options api.AccountQueryOptions, ctx context.Context) ([]string, api.BlockInfo, error)

GetNFTTokenIDsRegisteredByAddress returns all the token identifiers for semi or non fungible tokens registered by the address

func (*Node) GetNetworkComponents

func (n *Node) GetNetworkComponents() mainFactory.NetworkComponentsHolder

GetNetworkComponents returns the network components

func (*Node) GetPeerInfo

func (n *Node) GetPeerInfo(pid string) ([]core.QueryP2PPeerInfo, error)

GetPeerInfo returns information about a peer id

func (*Node) GetProcessComponents

func (n *Node) GetProcessComponents() mainFactory.ProcessComponentsHolder

GetProcessComponents returns the process components

func (*Node) GetProof

func (n *Node) GetProof(rootHash string, key string) (*common.GetProofResponse, error)

GetProof returns the Merkle proof for the given address and root hash

func (*Node) GetProofDataTrie

func (n *Node) GetProofDataTrie(rootHash string, address string, key string) (*common.GetProofResponse, *common.GetProofResponse, error)

GetProofDataTrie returns the Merkle Proof for the given address, and another Merkle Proof for the given key, if it exists in the dataTrie

func (*Node) GetQueryHandler

func (n *Node) GetQueryHandler(name string) (debug.QueryHandler, error)

GetQueryHandler returns the query handler if existing

func (*Node) GetStateComponents

func (n *Node) GetStateComponents() mainFactory.StateComponentsHolder

GetStateComponents returns the state components

func (*Node) GetStatusComponents

func (n *Node) GetStatusComponents() mainFactory.StatusComponentsHolder

GetStatusComponents returns the status components

func (*Node) GetStatusCoreComponents

func (n *Node) GetStatusCoreComponents() mainFactory.StatusCoreComponentsHolder

GetStatusCoreComponents returns the status core components

func (*Node) GetTokenSupply

func (n *Node) GetTokenSupply(token string) (*api.ESDTSupply, error)

GetTokenSupply returns the provided token supply from current shard

func (*Node) GetUsername

func (n *Node) GetUsername(address string, options api.AccountQueryOptions) (string, api.BlockInfo, error)

GetUsername gets the username for a specific address

func (*Node) GetValueForKey

func (n *Node) GetValueForKey(address string, key string, options api.AccountQueryOptions) (string, api.BlockInfo, error)

GetValueForKey will return the value for a key from a given account

func (*Node) IsDataTrieMigrated added in v1.6.0

func (n *Node) IsDataTrieMigrated(address string, options api.AccountQueryOptions) (bool, error)

IsDataTrieMigrated returns true if the data trie for the given address is migrated

func (*Node) IsInImportMode

func (n *Node) IsInImportMode() bool

IsInImportMode returns true if the node is in import mode

func (*Node) IsInterfaceNil

func (n *Node) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Node) IsSelfTrigger

func (n *Node) IsSelfTrigger() bool

IsSelfTrigger returns true if the trigger's registered public key matches the self public key

func (*Node) SendBulkTransactions

func (n *Node) SendBulkTransactions(txs []*transaction.Transaction) (uint64, error)

SendBulkTransactions sends the provided transactions as a bulk, optimizing transfer between nodes

func (*Node) ValidateTransaction

func (n *Node) ValidateTransaction(tx *transaction.Transaction) error

ValidateTransaction will validate a transaction

func (*Node) ValidateTransactionForSimulation

func (n *Node) ValidateTransactionForSimulation(tx *transaction.Transaction, checkSignature bool) error

ValidateTransactionForSimulation will validate a transaction for use in transaction simulation process

func (*Node) ValidatorStatisticsApi

func (n *Node) ValidatorStatisticsApi() (map[string]*accounts.ValidatorApiResponse, error)

ValidatorStatisticsApi will return the statistics for all the validators from the initial nodes pub keys

func (*Node) VerifyProof

func (n *Node) VerifyProof(rootHash string, address string, proof [][]byte) (bool, error)

VerifyProof verifies the given Merkle proof

type Option

type Option func(*Node) error

Option represents a functional configuration parameter that can operate

over the None struct.

func WithAddressSignatureSize

func WithAddressSignatureSize(signatureSize int) Option

WithAddressSignatureSize sets up an addressSignatureSize option for the Node

func WithBootstrapComponents

func WithBootstrapComponents(bootstrapComponents factory.BootstrapComponentsHandler) Option

WithBootstrapComponents sets up the Node bootstrap components

func WithBootstrapRoundIndex

func WithBootstrapRoundIndex(bootstrapRoundIndex uint64) Option

WithBootstrapRoundIndex sets up a bootstrapRoundIndex option for the Node

func WithConsensusComponents

func WithConsensusComponents(consensusComponents factory.ConsensusComponentsHandler) Option

WithConsensusComponents sets up the Node consensus components

func WithConsensusGroupSize

func WithConsensusGroupSize(consensusGroupSize int) Option

WithConsensusGroupSize sets up the consensus group size option for the Node

func WithConsensusType

func WithConsensusType(consensusType string) Option

WithConsensusType sets up the consensus type option for the Node

func WithCoreComponents

func WithCoreComponents(coreComponents factory.CoreComponentsHandler) Option

WithCoreComponents sets up the Node core components

func WithCryptoComponents

func WithCryptoComponents(cryptoComponents factory.CryptoComponentsHandler) Option

WithCryptoComponents sets up Node crypto components

func WithDataComponents

func WithDataComponents(dataComponents factory.DataComponentsHandler) Option

WithDataComponents sets up the Node data components

func WithESDTNFTStorageHandler

func WithESDTNFTStorageHandler(storageHandler vmcommon.ESDTNFTStorageHandler) Option

WithESDTNFTStorageHandler sets the esdt nft storage handler

func WithEnableSignTxWithHashEpoch

func WithEnableSignTxWithHashEpoch(enableSignTxWithHashEpoch uint32) Option

WithEnableSignTxWithHashEpoch sets up enableSignTxWithHashEpoch for the node

func WithGenesisTime

func WithGenesisTime(genesisTime time.Time) Option

WithGenesisTime sets up the genesis time option for the Node

func WithHeartbeatV2Components

func WithHeartbeatV2Components(heartbeatV2Components factory.HeartbeatV2ComponentsHandler) Option

WithHeartbeatV2Components sets up the Node heartbeatV2 components

func WithImportMode

func WithImportMode(importMode bool) Option

WithImportMode sets up the flag if the node is running in import mode

func WithInitialNodesPubKeys

func WithInitialNodesPubKeys(pubKeys map[uint32][]string) Option

WithInitialNodesPubKeys sets up the initial nodes public key option for the Node

func WithNetworkComponents

func WithNetworkComponents(networkComponents factory.NetworkComponentsHandler) Option

WithNetworkComponents sets up the Node network components

func WithNodeStopChannel

func WithNodeStopChannel(channel chan endProcess.ArgEndProcess) Option

WithNodeStopChannel sets up the channel which will handle closing the node

func WithPeerDenialEvaluator

func WithPeerDenialEvaluator(handler p2p.PeerDenialEvaluator) Option

WithPeerDenialEvaluator sets up a peer denial evaluator for the Node

func WithProcessComponents

func WithProcessComponents(processComponents factory.ProcessComponentsHandler) Option

WithProcessComponents sets up the Node process components

func WithPublicKeySize

func WithPublicKeySize(publicKeySize int) Option

WithPublicKeySize sets up a publicKeySize option for the Node

func WithRequestedItemsHandler

func WithRequestedItemsHandler(requestedItemsHandler dataRetriever.RequestedItemsHandler) Option

WithRequestedItemsHandler sets up a requested items handler for the Node

func WithRoundDuration

func WithRoundDuration(roundDuration uint64) Option

WithRoundDuration sets up the round duration option for the Node

func WithStateComponents

func WithStateComponents(stateComponents factory.StateComponentsHandler) Option

WithStateComponents sets up the Node state components

func WithStatusComponents

func WithStatusComponents(statusComponents factory.StatusComponentsHandler) Option

WithStatusComponents sets up the Node status components

func WithStatusCoreComponents

func WithStatusCoreComponents(statusCoreComponents factory.StatusCoreComponentsHandler) Option

WithStatusCoreComponents sets up the Node status core components

func WithValidatorSignatureSize

func WithValidatorSignatureSize(signatureSize int) Option

WithValidatorSignatureSize sets up a validatorSignatureSize option for the Node

type P2PAntifloodHandler

type P2PAntifloodHandler interface {
	CanProcessMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error
	CanProcessMessagesOnTopic(peer core.PeerID, topic string, numMessages uint32, totalSize uint64, sequence []byte) error
	ResetForTopic(topic string)
	SetMaxMessagesForTopic(topic string, maxNum uint32)
	ApplyConsensusSize(size int)
	BlacklistPeer(peer core.PeerID, reason string, duration time.Duration)
	IsInterfaceNil() bool
}

P2PAntifloodHandler defines the behavior of a component able to signal that the system is too busy (or flooded) processing p2p messages

type Throttler

type Throttler interface {
	CanProcess() bool
	StartProcessing()
	EndProcessing()
	IsInterfaceNil() bool
}

Throttler can monitor the number of the currently running go routines

Jump to

Keyboard shortcuts

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