Documentation
¶
Index ¶
- Constants
- Variables
- type Node
- func (n *Node) ApplyOptions(opts ...Option) error
- func (n *Node) BroadcastMetaBlock(blockBody data.BodyHandler, header data.HeaderHandler) error
- func (n *Node) BroadcastMetaHeader(headerHandler data.HeaderHandler) error
- func (n *Node) BroadcastShardBlock(blockBody data.BodyHandler, header data.HeaderHandler) error
- func (n *Node) BroadcastShardHeader(header data.HeaderHandler) error
- func (n *Node) CreateMetaGenesisBlock() error
- func (n *Node) CreateShardGenesisBlock() error
- func (n *Node) CreateShardedStores() error
- func (n *Node) GenerateAndSendBulkTransactions(receiverHex string, value *big.Int, noOfTx uint64) error
- func (n *Node) GenerateAndSendBulkTransactionsOneByOne(receiverHex string, value *big.Int, noOfTx uint64) error
- func (n *Node) GenerateTransaction(senderHex string, receiverHex string, value *big.Int, transactionData string) (*transaction.Transaction, error)
- func (n *Node) GetAccount(address string) (*state.Account, error)
- func (n *Node) GetBalance(addressHex string) (*big.Int, error)
- func (n *Node) GetCurrentPublicKey() string
- func (n *Node) GetHeartbeats() []heartbeat.PubKeyHeartbeat
- func (n *Node) GetTransaction(hash string) (*transaction.Transaction, error)
- func (n *Node) IsRunning() bool
- func (n *Node) P2PBootstrap() error
- func (n *Node) SendTransaction(nonce uint64, senderHex string, receiverHex string, value *big.Int, ...) (*transaction.Transaction, error)
- func (n *Node) Start() error
- func (n *Node) StartConsensus() error
- func (n *Node) StartHeartbeat(config config.HeartbeatConfig) error
- func (n *Node) Stop() error
- type Option
- func WithAccountsAdapter(accounts state.AccountsAdapter) Option
- func WithActiveMetachain(flag bool) Option
- func WithAddressConverter(addrConverter state.AddressConverter) Option
- func WithBlockChain(blkc data.ChainHandler) Option
- func WithBlockProcessor(blockProcessor process.BlockProcessor) Option
- func WithBlockTracker(blockTracker process.BlocksTracker) Option
- func WithConsensusGroupSize(consensusGroupSize int) Option
- func WithConsensusType(consensusType string) Option
- func WithDataPool(dataPool dataRetriever.PoolsHolder) Option
- func WithDataStore(store dataRetriever.StorageService) Option
- func WithForkDetector(forkDetector process.ForkDetector) Option
- func WithGenesisTime(genesisTime time.Time) Option
- func WithHasher(hasher hashing.Hasher) Option
- func WithInitialNodesBalances(balances map[string]*big.Int) Option
- func WithInitialNodesPubKeys(pubKeys map[uint32][]string) Option
- func WithInterceptorsContainer(interceptorsContainer process.InterceptorsContainer) Option
- func WithKeyGen(keyGen crypto.KeyGenerator) Option
- func WithMarshalizer(marshalizer marshal.Marshalizer) Option
- func WithMessenger(mes P2PMessenger) Option
- func WithMetaDataPool(dataPool dataRetriever.MetaPoolsHolder) Option
- func WithMultiSigner(multiSigner crypto.MultiSigner) Option
- func WithPrivKey(sk crypto.PrivateKey) Option
- func WithPubKey(pk crypto.PublicKey) Option
- func WithResolversFinder(resolversFinder dataRetriever.ResolversFinder) Option
- func WithRoundDuration(roundDuration uint64) Option
- func WithRounder(rounder consensus.Rounder) Option
- func WithShardCoordinator(shardCoordinator sharding.Coordinator) Option
- func WithSingleSigner(singleSigner crypto.SingleSigner) Option
- func WithSyncer(syncer ntp.SyncTimer) Option
- func WithTxSignPrivKey(sk crypto.PrivateKey) Option
- func WithTxSignPubKey(pk crypto.PublicKey) Option
- func WithTxSingleSigner(txSingleSigner crypto.SingleSigner) Option
- func WithTxStorageSize(txStorageSize uint32) Option
- func WithUint64ByteSliceConverter(converter typeConverters.Uint64ByteSliceConverter) Option
- type P2PMessenger
Constants ¶
const ConsensusTopic = "consensus"
ConsensusTopic is the topic used in consensus algorithm
const HeartbeatTopic = "heartbeat"
HeartbeatTopic is the topic used for heartbeat signaling
const SendTransactionsPipe = "send transactions pipe"
SendTransactionsPipe is the pipe used for sending new transactions
const WaitTime = time.Duration(2000 * time.Millisecond)
WaitTime defines the time in milliseconds until node waits the requested info from the network
Variables ¶
var ErrGenesisBlockNotInitialized = errors.New("genesis block is not initialized")
ErrGenesisBlockNotInitialized signals that genesis block is not initialized
var ErrNegativeDurationInSecToConsiderUnresponsive = errors.New("value DurationInSecToConsiderUnresponsive is less" +
" than 1")
ErrNegativeDurationInSecToConsiderUnresponsive is raised when a value less than 1 has been provided
var ErrNegativeMaxTimeToWaitBetweenBroadcastsInSec = errors.New("value MaxTimeToWaitBetweenBroadcastsInSec is less " +
"than 1")
ErrNegativeMaxTimeToWaitBetweenBroadcastsInSec is raised when a value less than 1 has been provided
var ErrNegativeMinTimeToWaitBetweenBroadcastsInSec = errors.New("value MinTimeToWaitBetweenBroadcastsInSec is less " +
"than 1")
ErrNegativeMinTimeToWaitBetweenBroadcastsInSec is raised when a value less than 1 has been provided
var ErrNegativeOrZeroConsensusGroupSize = errors.New("group size should be a strict positive number")
ErrNegativeOrZeroConsensusGroupSize signals that 0 elements consensus group is not supported
var ErrNilAccountsAdapter = errors.New("trying to set nil accounts adapter")
ErrNilAccountsAdapter signals that a nil accounts adapter has been provided
var ErrNilAddressConverter = errors.New("trying to set nil address converter")
ErrNilAddressConverter signals that a nil address converter has been provided
var ErrNilBalances = errors.New("trying to set nil balances")
ErrNilBalances signals that a nil list of initial balances has been provided
var ErrNilBlockHeader = errors.New("block header is nil")
ErrNilBlockHeader is raised when a valid block header is expected but nil was used
var ErrNilBlockProcessor = errors.New("trying to set nil block processor")
ErrNilBlockProcessor signals that a nil block processor has been provided
var ErrNilBlockTracker = errors.New("trying to set nil block tracker")
ErrNilBlockTracker signals that a nil block tracker has been provided
var ErrNilBlockchain = errors.New("nil blockchain")
ErrNilBlockchain signals that a nil blockchain structure has been provided
var ErrNilDataPool = errors.New("trying to set nil data pool")
ErrNilDataPool signals that a nil data pool has been provided
var ErrNilForkDetector = errors.New("nil fork detector")
ErrNilForkDetector signals that a nil forkdetector object has been provided
var ErrNilHasher = errors.New("trying to set nil hasher")
ErrNilHasher signals that a nil hasher has been provided
var ErrNilInterceptorsContainer = errors.New("nil interceptors container")
ErrNilInterceptorsContainer signals that a nil interceptors container has been provided
var ErrNilMarshalizer = errors.New("trying to set nil marshalizer")
ErrNilMarshalizer signals that a nil marshalizer has been provided
var ErrNilMessenger = errors.New("nil messenger")
ErrNilMessenger signals that a nil messenger has been provided
var ErrNilMetaBlockHeader = errors.New("meta block header is nil")
ErrNilMetaBlockHeader is raised when a valid metablock is expected but nil was provided
var ErrNilMultiSig = errors.New("trying to set nil multiSigner")
ErrNilMultiSig signals that a nil multiSigner object has been provided
var ErrNilPrivateKey = errors.New("trying to set nil private key")
ErrNilPrivateKey signals that a nil private key has been provided
var ErrNilPublicKey = errors.New("trying to set nil public key")
ErrNilPublicKey signals that a nil public key has been provided
var ErrNilResolversFinder = errors.New("nil resolvers finder")
ErrNilResolversFinder signals that a nil resolvers finder has been provided
var ErrNilRounder = errors.New("trying to set nil rounder")
ErrNilRounder signals that a nil rounder has been provided
var ErrNilShardCoordinator = errors.New("trying to set nil shard coordinator")
ErrNilShardCoordinator signals that a nil shard coordinator has been provided
var ErrNilSingleSig = errors.New("trying to set nil schnorrSingleSigner")
ErrNilSingleSig signals that a nil schnorrSingleSigner object has been provided
var ErrNilSingleSignKeyGen = errors.New("trying to set nil single sign key generator")
ErrNilSingleSignKeyGen signals that a nil single key generator has been provided
var ErrNilStore = errors.New("nil data store")
ErrNilStore signals that a nil store has been provided
var ErrNilSyncTimer = errors.New("trying to set nil sync timer")
ErrNilSyncTimer signals that a nil sync timer has been provided
var ErrNilTransactionPool = errors.New("nil transaction pool")
ErrNilTransactionPool signals that a nil transaction pool was used
var ErrNilTxBlockBody = errors.New("tx block body is nil")
ErrNilTxBlockBody is raised when a valid tx block body is expected but nil was used
var ErrNilUint64ByteSliceConverter = errors.New("trying to set nil uint64 - byte slice converter")
ErrNilUint64ByteSliceConverter signals that a nil uint64 <-> byte slice converter has been provided
var ErrTooManyTransactionsInPool = errors.New("too many transactions in pool")
ErrTooManyTransactionsInPool signals that are too many transactions in pool
var ErrValidatorAlreadySet = errors.New("topic validator has already been set")
ErrValidatorAlreadySet signals that a topic validator has already been set
var ErrWrongTypeAssertion = errors.New("wrong type assertion: expected *block.Header")
ErrWrongTypeAssertion is raised when a type assertion occurs
var ErrWrongValues = errors.New("wrong values for heartbeat parameters")
ErrWrongValues signals that wrong values were provided
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 (*Node) ApplyOptions ¶
ApplyOptions can set up different configurable options of a Node instance
func (*Node) BroadcastMetaBlock ¶
func (n *Node) BroadcastMetaBlock(blockBody data.BodyHandler, header data.HeaderHandler) error
BroadcastMetaBlock will send on meta shard topics the header and on meta-to-shard topics the header. This func needs to be exported as it is tested in integrationTests package.
func (*Node) BroadcastMetaHeader ¶
func (n *Node) BroadcastMetaHeader(headerHandler data.HeaderHandler) error
BroadcastMetaHeader will send on metachain topics the header
func (*Node) BroadcastShardBlock ¶
func (n *Node) BroadcastShardBlock(blockBody data.BodyHandler, header data.HeaderHandler) error
BroadcastShardBlock will send on intra shard topics the header and block body and on cross shard topics the miniblocks. This func needs to be exported as it is tested in integrationTests package. TODO: investigate if the body block needs to be sent on intra shard topic as each miniblock is already sent on cross
shard topics
func (*Node) BroadcastShardHeader ¶
func (n *Node) BroadcastShardHeader(header data.HeaderHandler) error
BroadcastShardHeader will send on metachain topics the header
func (*Node) CreateMetaGenesisBlock ¶
CreateMetaGenesisBlock creates the meta genesis block
func (*Node) CreateShardGenesisBlock ¶
CreateShardGenesisBlock creates the shard genesis block
func (*Node) CreateShardedStores ¶
CreateShardedStores instantiate sharded cachers for Transactions and Headers
func (*Node) GenerateAndSendBulkTransactions ¶
func (n *Node) GenerateAndSendBulkTransactions(receiverHex string, value *big.Int, noOfTx 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) GenerateAndSendBulkTransactionsOneByOne ¶
func (n *Node) GenerateAndSendBulkTransactionsOneByOne(receiverHex string, value *big.Int, noOfTx uint64) error
GenerateAndSendBulkTransactionsOneByOne 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 ¶
GetAccount will return acount details for a given address
func (*Node) GetBalance ¶
GetBalance gets the balance for a specific address
func (*Node) GetCurrentPublicKey ¶
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) P2PBootstrap ¶
P2PBootstrap will try to connect to many peers as possible
func (*Node) SendTransaction ¶
func (n *Node) SendTransaction( nonce uint64, senderHex string, receiverHex string, value *big.Int, transactionData string, signature []byte) (*transaction.Transaction, error)
SendTransaction will send a new transaction on the topic channel
func (*Node) StartConsensus ¶
StartConsensus will start the consesus service for the current node
func (*Node) StartHeartbeat ¶
func (n *Node) StartHeartbeat(config config.HeartbeatConfig) error
StartHeartbeat starts the node's heartbeat processing/signaling module
type Option ¶
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 WithActiveMetachain ¶
WithActiveMetachain sets up the flag that tells the node that metachain shard is active TODO - remove this when finishing metachain testing as it will always be enabled
func WithAddressConverter ¶
func WithAddressConverter(addrConverter state.AddressConverter) Option
WithAddressConverter sets up the address converter adapter option 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 WithBlockTracker ¶
func WithBlockTracker(blockTracker process.BlocksTracker) Option
WithBlockTracker sets up the block tracker option for the Node
func WithConsensusGroupSize ¶
WithConsensusGroupSize sets up the consensus group size option for the Node
func WithConsensusType ¶
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 ¶
WithGenesisTime sets up the genesis time option for the Node
func WithHasher ¶
WithHasher sets up the hasher option for the Node
func WithInitialNodesBalances ¶
WithInitialNodesBalances sets up the initial map of nodes public keys and their respective balances
func WithInitialNodesPubKeys ¶
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 WithMarshalizer ¶
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 ¶
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 WithPrivKey ¶
func WithPrivKey(sk crypto.PrivateKey) Option
WithPrivKey sets up the multi sign private key option for the Node
func WithPubKey ¶
WithPubKey sets up the multi sign pub key option for the Node
func WithResolversFinder ¶
func WithResolversFinder(resolversFinder dataRetriever.ResolversFinder) Option
WithResolversFinder sets up the resolvers finder option for the Node
func WithRoundDuration ¶
WithRoundDuration sets up the round duration option for the Node
func WithRounder ¶
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 ¶
WithSyncer sets up the syncTimer option for the Node
func WithTxSignPrivKey ¶
func WithTxSignPrivKey(sk crypto.PrivateKey) Option
WithTxSignPrivKey sets up the single sign private key option for the Node
func WithTxSignPubKey ¶
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 ¶
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) 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 }
P2PMessenger defines a subset of the p2p.Messenger interface