node

package
v1.0.52 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: GPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const HeartbeatTopic = "heartbeat"

HeartbeatTopic is the topic used for heartbeat signaling

View Source
const SendTransactionsPipe = "send transactions pipe"

SendTransactionsPipe is the pipe used for sending new transactions

Variables

View Source
var ErrGenesisBlockNotInitialized = errors.New("genesis block is not initialized")

ErrGenesisBlockNotInitialized signals that genesis block is not initialized

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 ErrNegativeDurationInSecToConsiderUnresponsive = errors.New("value DurationInSecToConsiderUnresponsive is less" +
	" than 1")

ErrNegativeDurationInSecToConsiderUnresponsive is raised when a value less than 1 has been provided

View Source
var ErrNegativeMaxTimeToWaitBetweenBroadcastsInSec = errors.New("value MaxTimeToWaitBetweenBroadcastsInSec is less " +
	"than 1")

ErrNegativeMaxTimeToWaitBetweenBroadcastsInSec is raised when a value less than 1 has been provided

View Source
var ErrNegativeMinTimeToWaitBetweenBroadcastsInSec = errors.New("value MinTimeToWaitBetweenBroadcastsInSec is less " +
	"than 1")

ErrNegativeMinTimeToWaitBetweenBroadcastsInSec is raised when a value less than 1 has been provided

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 ErrNilAddressConverter = errors.New("trying to set nil address converter")

ErrNilAddressConverter signals that a nil address converter has been provided

View Source
var ErrNilBalances = errors.New("trying to set nil balances")

ErrNilBalances signals that a nil list of initial balances has been provided

View Source
var ErrNilBlackListHandler = errors.New("nil black list handler")

ErrNilBlackListHandler signals that a nil black list handler was provided

View Source
var ErrNilBlockHeader = errors.New("block header is nil")

ErrNilBlockHeader is raised when a valid block header is expected but nil was used

View Source
var ErrNilBlockProcessor = errors.New("trying to set nil block processor")

ErrNilBlockProcessor signals that a nil block processor has been provided

View Source
var ErrNilBlockchain = errors.New("nil blockchain")

ErrNilBlockchain signals that a nil blockchain structure has been provided

View Source
var ErrNilBootStorer = errors.New("nil boot storer")

ErrNilBootStorer signals that a nil boot storer was 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 ErrNilForkDetector = errors.New("nil fork detector")

ErrNilForkDetector signals that a nil forkdetector object has been provided

View Source
var ErrNilHasher = errors.New("trying to set nil hasher")

ErrNilHasher signals that a nil hasher has been provided

View Source
var ErrNilInterceptorsContainer = errors.New("nil interceptors container")

ErrNilInterceptorsContainer signals that a nil interceptors container has been provided

View Source
var ErrNilKeyGenForBalances = errors.New("trying to set a nil key gen for signing")

ErrNilKeyGenForBalances signals that a nil keygen for balances 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 ErrNilMessenger = errors.New("nil messenger")

ErrNilMessenger signals that a nil messenger has been provided

View Source
var ErrNilMultiSig = errors.New("trying to set nil multiSigner")

ErrNilMultiSig signals that a nil multiSigner object has been provided

View Source
var ErrNilNodesCoordinator = errors.New("trying to set nil nodes coordinator")

ErrNilNodesCoordinator signals that a nil nodes coordinator has been 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 ErrNilPublicKey = errors.New("trying to set nil public key")

ErrNilPublicKey signals that a nil public key 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 ErrNilResolversFinder = errors.New("nil resolvers finder")

ErrNilResolversFinder signals that a nil resolvers finder has been provided

View Source
var ErrNilRounder = errors.New("trying to set nil rounder")

ErrNilRounder signals that a nil rounder has been 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 ErrNilSingleSignKeyGen = errors.New("trying to set nil single sign key generator")

ErrNilSingleSignKeyGen signals that a nil single key generator has been provided

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

ErrNilStatusHandler is returned when the status handler is nil

View Source
var ErrNilStore = errors.New("nil data store")

ErrNilStore signals that a nil store has been provided

View Source
var ErrNilSyncTimer = errors.New("trying to set nil sync timer")

ErrNilSyncTimer signals that a nil sync timer has been provided

View Source
var ErrNilTxBlockBody = errors.New("tx block body is nil")

ErrNilTxBlockBody is raised when a valid tx block body is expected but nil was used

View Source
var ErrNilTxFeeHandler = errors.New("trying to set a nil tx fee handler")

ErrNilTxFeeHandler signals that a nil tx fee handler was provided

View Source
var ErrNilUint64ByteSliceConverter = errors.New("trying to set nil uint64 - byte slice converter")

ErrNilUint64ByteSliceConverter signals that a nil uint64 <-> byte slice converter has been provided

View Source
var ErrNoTxToProcess = errors.New("no transaction to process")

ErrNoTxToProcess signals that no transaction were sent for processing

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 ErrValidatorAlreadySet = errors.New("topic validator has already been set")

ErrValidatorAlreadySet signals that a topic validator has already been set

View Source
var ErrWrongTypeAssertion = errors.New("wrong type assertion: expected *block.Header")

ErrWrongTypeAssertion is raised when a type assertion occurs

View Source
var ErrWrongValues = errors.New("wrong values for heartbeat parameters")

ErrWrongValues signals that wrong values were provided

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

ErrZeroRoundDurationNotSupported signals that 0 seconds round duration is not supported

Functions

This section is empty.

Types

type Node

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

Node is a structure that passes the configuration parameters and initializes

required services as requested

func NewNode

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

NewNode creates a new Node instance

func (*Node) ApplyOptions

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

ApplyOptions can set up different configurable options of a Node instance

func (*Node) CreateShardedStores

func (n *Node) CreateShardedStores() error

CreateShardedStores instantiate sharded cachers for Transactions and Headers

func (*Node) CreateTransaction

func (n *Node) CreateTransaction(
	nonce uint64,
	value string,
	receiverHex string,
	senderHex string,
	gasPrice uint64,
	gasLimit uint64,
	data string,
	signatureHex string,
	challenge string,
) (*transaction.Transaction, error)

CreateTransaction will return a transaction from all the required fields

func (*Node) GenerateAndSendBulkTransactions

func (n *Node) GenerateAndSendBulkTransactions(receiverHex string, value *big.Int, numOfTxs uint64) 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) (*transaction.Transaction, error)

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

func (*Node) GetAccount

func (n *Node) GetAccount(address string) (*state.Account, error)

GetAccount will return acount details for a given address

func (*Node) GetAppStatusHandler

func (n *Node) GetAppStatusHandler() core.AppStatusHandler

GetAppStatusHandler will return the current status handler

func (*Node) GetBalance

func (n *Node) GetBalance(addressHex string) (*big.Int, error)

GetBalance gets the balance for a specific address

func (*Node) GetCurrentPublicKey added in v1.0.3

func (n *Node) GetCurrentPublicKey() string

GetCurrentPublicKey will return the current node's public key

func (*Node) GetHeartbeats

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

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

func (*Node) GetTransaction

func (n *Node) GetTransaction(hash string) (*transaction.Transaction, error)

GetTransaction gets the transaction

func (*Node) IsInterfaceNil

func (n *Node) IsInterfaceNil() bool

IsInterfaceNil returns true if there is no value under the interface

func (*Node) IsRunning

func (n *Node) IsRunning() bool

IsRunning will return the current state of the node

func (*Node) P2PBootstrap

func (n *Node) P2PBootstrap() error

P2PBootstrap will try to connect to many peers as possible

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

func (n *Node) SendTransaction(
	nonce uint64,
	senderHex string,
	receiverHex string,
	value string,
	gasPrice uint64,
	gasLimit uint64,
	transactionData string,
	signature []byte) (string, error)

SendTransaction will send a new transaction on the topic channel

func (*Node) Start

func (n *Node) Start() error

Start will create a new messenger and and set up the Node state as running

func (*Node) StartConsensus

func (n *Node) StartConsensus() error

StartConsensus will start the consensus service for the current node

func (*Node) StartHeartbeat

func (n *Node) StartHeartbeat(hbConfig config.HeartbeatConfig, versionNumber string, nodeDisplayName string) error

StartHeartbeat starts the node's heartbeat processing/signaling module

func (*Node) Stop

func (n *Node) Stop() error

Stop closes the messenger and undos everything done in Start

type Option

type Option func(*Node) error

Option represents a functional configuration parameter that can operate

over the None struct.

func WithAccountsAdapter

func WithAccountsAdapter(accounts state.AccountsAdapter) Option

WithAccountsAdapter sets up the accounts adapter option for the Node

func WithAddressConverter

func WithAddressConverter(addrConverter state.AddressConverter) Option

WithAddressConverter sets up the address converter adapter option for the Node

func WithAppStatusHandler

func WithAppStatusHandler(aph core.AppStatusHandler) Option

WithAppStatusHandler sets up which handler will monitor the status of the node

func WithBlackListHandler

func WithBlackListHandler(blackListHandler process.BlackListHandler) Option

WithBlackListHandler sets up a black list handler for the Node

func WithBlockChain

func WithBlockChain(blkc data.ChainHandler) Option

WithBlockChain sets up the blockchain option for the Node

func WithBlockProcessor

func WithBlockProcessor(blockProcessor process.BlockProcessor) Option

WithBlockProcessor sets up the block processor option for the Node

func WithBootStorer

func WithBootStorer(bootStorer process.BootStorer) Option

WithBootStorer sets up a boot storer for the Node

func WithBootstrapRoundIndex

func WithBootstrapRoundIndex(bootstrapRoundIndex uint64) Option

WithBootstrapRoundIndex sets up a bootstrapRoundIndex option for the Node

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 WithDataPool

func WithDataPool(dataPool dataRetriever.PoolsHolder) Option

WithDataPool sets up the data pools option for the Node

func WithDataStore

func WithDataStore(store dataRetriever.StorageService) Option

WithDataStore sets up the storage options for the Node

func WithForkDetector

func WithForkDetector(forkDetector process.ForkDetector) Option

WithForkDetector sets up the multiSigner option for the Node

func WithGenesisTime

func WithGenesisTime(genesisTime time.Time) Option

WithGenesisTime sets up the genesis time option for the Node

func WithHasher

func WithHasher(hasher hashing.Hasher) Option

WithHasher sets up the hasher option for the Node

func WithIndexer

func WithIndexer(indexer indexer.Indexer) Option

WithIndexer sets up a indexer for the Node

func WithInitialNodesBalances added in v1.0.3

func WithInitialNodesBalances(balances map[string]*big.Int) Option

WithInitialNodesBalances sets up the initial map of nodes public keys and their respective balances

func WithInitialNodesPubKeys

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

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

func WithInterceptorsContainer

func WithInterceptorsContainer(interceptorsContainer process.InterceptorsContainer) Option

WithInterceptorsContainer sets up the interceptors container option for the Node

func WithKeyGen

func WithKeyGen(keyGen crypto.KeyGenerator) Option

WithKeyGen sets up the single sign key generator option for the Node

func WithKeyGenForAccounts

func WithKeyGenForAccounts(keyGenForAccounts crypto.KeyGenerator) Option

WithKeyGenForAccounts sets up the balances key generator option for the Node

func WithMarshalizer added in v1.0.3

func WithMarshalizer(marshalizer marshal.Marshalizer) Option

WithMarshalizer sets up the marshalizer option for the Node

func WithMessenger

func WithMessenger(mes P2PMessenger) Option

WithMessenger sets up the messenger option for the Node

func WithMetaDataPool added in v1.0.3

func WithMetaDataPool(dataPool dataRetriever.MetaPoolsHolder) Option

WithMetaDataPool sets up the data pools option for the Node

func WithMultiSigner

func WithMultiSigner(multiSigner crypto.MultiSigner) Option

WithMultiSigner sets up the multiSigner option for the Node

func WithNodesCoordinator

func WithNodesCoordinator(nodesCoordinator sharding.NodesCoordinator) Option

WithNodesCoordinator sets up the nodes coordinator

func WithPrivKey

func WithPrivKey(sk crypto.PrivateKey) Option

WithPrivKey sets up the multi sign private key option for the Node

func WithPubKey

func WithPubKey(pk crypto.PublicKey) Option

WithPubKey sets up the multi sign pub key option for the Node

func WithRequestedItemsHandler

func WithRequestedItemsHandler(requestedItemsHandler dataRetriever.RequestedItemsHandler) Option

WithRequestedItemsHandler sets up a requested items handler for the Node

func WithResolversFinder

func WithResolversFinder(resolversFinder dataRetriever.ResolversFinder) Option

WithResolversFinder sets up the resolvers finder option for the Node

func WithRoundDuration

func WithRoundDuration(roundDuration uint64) Option

WithRoundDuration sets up the round duration option for the Node

func WithRounder

func WithRounder(rounder consensus.Rounder) Option

WithRounder sets up the rounder option for the Node

func WithShardCoordinator

func WithShardCoordinator(shardCoordinator sharding.Coordinator) Option

WithShardCoordinator sets up the shard coordinator for the Node

func WithSingleSigner

func WithSingleSigner(singleSigner crypto.SingleSigner) Option

WithSingleSigner sets up a singleSigner option for the Node

func WithSyncer

func WithSyncer(syncer ntp.SyncTimer) Option

WithSyncer sets up the syncTimer option for the Node

func WithTxFeeHandler

func WithTxFeeHandler(feeHandler process.FeeHandler) Option

WithTxFeeHandler sets up the tx fee handler for the Node

func WithTxSignPrivKey added in v1.0.3

func WithTxSignPrivKey(sk crypto.PrivateKey) Option

WithTxSignPrivKey sets up the single sign private key option for the Node

func WithTxSignPubKey added in v1.0.3

func WithTxSignPubKey(pk crypto.PublicKey) Option

WithTxSignPubKey sets up the single sign public key option for the Node

func WithTxSingleSigner

func WithTxSingleSigner(txSingleSigner crypto.SingleSigner) Option

WithTxSingleSigner sets up a txSingleSigner option for the Node

func WithTxStorageSize

func WithTxStorageSize(txStorageSize uint32) Option

WithTxStorageSize sets up a txStorageSize option for the Node

func WithUint64ByteSliceConverter

func WithUint64ByteSliceConverter(converter typeConverters.Uint64ByteSliceConverter) Option

WithUint64ByteSliceConverter sets up the uint64 <-> []byte converter

type P2PMessenger

type P2PMessenger interface {
	io.Closer
	Bootstrap() error
	Broadcast(topic string, buff []byte)
	BroadcastOnChannel(channel string, topic string, buff []byte)
	BroadcastOnChannelBlocking(channel string, topic string, buff []byte) error
	CreateTopic(name string, createChannelForTopic bool) error
	HasTopic(name string) bool
	HasTopicValidator(name string) bool
	RegisterMessageProcessor(topic string, handler p2p.MessageProcessor) error
	PeerAddress(pid p2p.PeerID) string
	IsConnectedToTheNetwork() bool
	IsInterfaceNil() bool
}

P2PMessenger defines a subset of the p2p.Messenger interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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