Versions in this module Expand all Collapse all v1 v1.1.66 Jun 17, 2021 v1.1.65 Jun 17, 2021 Changes in this version + var ErrCouldNotParseAddress = errors.New("could not parse node's address") + var ErrCouldNotParsePubKey = errors.New("could not parse node's public key") + var ErrEpochNodesConfigDoesNotExist = errors.New("epoch nodes configuration does not exist") + var ErrInvalidConsensusGroupSize = errors.New("invalid consensus group size") + var ErrInvalidMaximumNumberOfShards = errors.New("trying to set an invalid maximum number of shards") + var ErrInvalidNumberOfShards = errors.New("the number of shards must be greater than zero") + var ErrInvalidNumberPubKeys = errors.New("invalid number of public keys") + var ErrInvalidSampleSize = errors.New("invalid sample size") + var ErrInvalidShardId = errors.New("shard id must be smaller than the total number of shards") + var ErrInvalidWeight = errors.New("invalid weight") + var ErrMapSizeZero = errors.New("map size zero") + var ErrMinNodesPerShardSmallerThanConsensusSize = errors.New("minimum nodes per shard is smaller than consensus group size") + var ErrNegativeOrZeroConsensusGroupSize = errors.New("negative or zero consensus group size") + var ErrNilBlockBody = errors.New("nil block body") + var ErrNilBootStorer = errors.New("nil boot storer provided") + var ErrNilCacher = errors.New("nil cacher") + var ErrNilChanceComputer = errors.New("nil chance computer") + var ErrNilEndOfProcessingHandler = errors.New("nil end of processing handler") + var ErrNilEpochNotifier = errors.New("nil epoch notifier") + var ErrNilHasher = errors.New("nil hasher") + var ErrNilInputNodesMap = errors.New("nil input nodes map") + var ErrNilMarshalizer = errors.New("nil marshalizer") + var ErrNilNodeShufflerArguments = errors.New("nil arguments for the creation of a node shuffler") + var ErrNilNodesCoordinator = errors.New("nil nodesCoordinator") + var ErrNilOrEmptyDestinationForDistribute = errors.New("nil or empty destination list for distributeNodes") + var ErrNilOwnPublicKey = errors.New("nil own public key") + var ErrNilPreviousEpochConfig = errors.New("nil previous epoch config") + var ErrNilPubKey = errors.New("nil public key") + var ErrNilPubkeyConverter = errors.New("trying to set nil pubkey converter") + var ErrNilRandomSelector = errors.New("nil selector") + var ErrNilRandomness = errors.New("nil randomness source") + var ErrNilShardCoordinator = errors.New("trying to set nil shard coordinator") + var ErrNilShuffledOutHandler = errors.New("nil shuffled out handler") + var ErrNilShuffler = errors.New("nil nodes shuffler provided") + var ErrNilWeights = errors.New("nil weights") + var ErrNoPubKeys = errors.New("no public keys defined") + var ErrNodesSizeSmallerThanMinNoOfNodes = errors.New("length of nodes defined is smaller than min nodes per shard required") + var ErrNotImplemented = errors.New("feature not implemented") + var ErrPublicKeyNotFoundInGenesis = errors.New("public key is not valid, it is missing from genesis file") + var ErrShardIdOutOfRange = errors.New("shard id out of range") + var ErrSmallMetachainEligibleListSize = errors.New("small metachain eligible list size") + var ErrSmallShardEligibleListSize = errors.New("small shard eligible list size") + var ErrValidatorNotFound = errors.New("validator not found") + var ErrWrongTypeAssertion = errors.New("wrong type assertion") + func NewHashValidatorsShuffler(args *NodesShufflerArgs) (*randHashShuffler, error) + func NewIndexHashedNodesCoordinator(arguments ArgNodesCoordinator) (*indexHashedNodesCoordinator, error) + func NewIndexHashedNodesCoordinatorWithRater(indexNodesCoordinator *indexHashedNodesCoordinator, ...) (*indexHashedNodesCoordinatorWithRater, error) + func NewMultiShardCoordinator(numberOfShards, selfId uint32) (*multiShardCoordinator, error) + func NewSelectorExpandedList(weightList []uint32, hasher hashing.Hasher) (*selectorExpandedList, error) + func NewSelectorWRS(weightList []uint32, hasher hashing.Hasher) (*selectorWRS, error) + func NewShuffledOutTrigger(ownPubKey []byte, currentShardID uint32, ...) (*shuffledOutTrigger, error) + func NewValidator(pubKey []byte, chances uint32, index uint32) (*validator, error) + func NodesInfoToValidators(nodesInfo map[uint32][]GenesisNodeInfoHandler) (map[uint32][]Validator, error) + func SerializableValidatorsToValidators(nodeRegistryValidators map[string][]*SerializableValidator) (map[uint32][]Validator, error) + type ArgNodesCoordinator struct + BootStorer storage.Storer + ConsensusGroupCache Cacher + EligibleNodes map[uint32][]Validator + Epoch uint32 + EpochStartNotifier EpochStartEventNotifier + Hasher hashing.Hasher + Marshalizer marshal.Marshalizer + MetaConsensusGroupSize int + NbShards uint32 + SelfPublicKey []byte + ShardConsensusGroupSize int + ShardIDAsObserver uint32 + ShuffledOutHandler ShuffledOutHandler + Shuffler NodesShuffler + StartEpoch uint32 + WaitingListFixEnabledEpoch uint32 + WaitingNodes map[uint32][]Validator + type ArgsUpdateNodes struct + AdditionalLeaving []Validator + Eligible map[uint32][]Validator + Epoch uint32 + NbShards uint32 + NewNodes []Validator + Rand []byte + UnStakeLeaving []Validator + Waiting map[uint32][]Validator + type Cacher interface + Clear func() + Get func(key []byte) (value interface{}, ok bool) + Put func(key []byte, value interface{}, sizeInBytes int) (evicted bool) + type ChanceComputer interface + GetChance func(uint32) uint32 + IsInterfaceNil func() bool + type Coordinator interface + CommunicationIdentifier func(destShardID uint32) string + ComputeId func(address []byte) uint32 + IsInterfaceNil func() bool + NumberOfShards func() uint32 + SameShard func(firstAddress, secondAddress []byte) bool + SelfId func() uint32 + type CrossShardValidatorDistributor struct + func (vd *CrossShardValidatorDistributor) DistributeValidators(destination map[uint32][]Validator, source map[uint32][]Validator, rand []byte, ...) error + func (vd *CrossShardValidatorDistributor) IsInterfaceNil() bool + type EpochHandler interface + IsInterfaceNil func() bool + MetaEpoch func() uint32 + type EpochStartActionHandler interface + EpochStartAction func(hdr data.HeaderHandler) + EpochStartPrepare func(metaHdr data.HeaderHandler, body data.BodyHandler) + NotifyOrder func() uint32 + type EpochStartEventNotifier interface + IsInterfaceNil func() bool + RegisterHandler func(handler epochStart.ActionHandler) + UnregisterHandler func(handler epochStart.ActionHandler) + type EpochValidators struct + EligibleValidators map[string][]*SerializableValidator + LeavingValidators map[string][]*SerializableValidator + WaitingValidators map[string][]*SerializableValidator + type GenesisNodeInfoHandler interface + AddressBytes func() []byte + AssignedShard func() uint32 + GetInitialRating func() uint32 + IsInterfaceNil func() bool + PubKeyBytes func() []byte + type GenesisNodesSetupHandler interface + GetChainId func() string + GetMetaConsensusGroupSize func() uint32 + GetMinTransactionVersion func() uint32 + GetRoundDuration func() uint64 + GetShardConsensusGroupSize func() uint32 + GetStartTime func() int64 + InitialNodesInfo func() (map[uint32][]GenesisNodeInfoHandler, map[uint32][]GenesisNodeInfoHandler) + InitialNodesInfoForShard func(shardId uint32) ([]GenesisNodeInfoHandler, []GenesisNodeInfoHandler, error) + IsInterfaceNil func() bool + MinNumberOfNodes func() uint32 + MinNumberOfNodesWithHysteresis func() uint32 + NumberOfShards func() uint32 + type InitialNode struct + Address string + InitialRating uint32 + PubKey string + type IntraShardValidatorDistributor struct + func (vd *IntraShardValidatorDistributor) DistributeValidators(destination map[uint32][]Validator, source map[uint32][]Validator, _ []byte, ...) error + func (vd *IntraShardValidatorDistributor) IsInterfaceNil() bool + type NodeInfo struct + func (ni *NodeInfo) AddressBytes() []byte + func (ni *NodeInfo) AssignedShard() uint32 + func (ni *NodeInfo) GetInitialRating() uint32 + func (ni *NodeInfo) IsInterfaceNil() bool + func (ni *NodeInfo) PubKeyBytes() []byte + type NodesCoordinator interface + ComputeConsensusGroup func(randomness []byte, round uint64, shardId uint32, epoch uint32) (validatorsGroup []Validator, err error) + ConsensusGroupSize func(uint32) int + GetConsensusWhitelistedNodes func(epoch uint32) (map[string]struct{}, error) + GetNumTotalEligible func() uint64 + GetSavedStateKey func() []byte + GetValidatorWithPublicKey func(publicKey []byte) (validator Validator, shardId uint32, err error) + IsInterfaceNil func() bool + LoadState func(key []byte) error + ShardIdForEpoch func(epoch uint32) (uint32, error) + ShuffleOutForEpoch func(_ uint32) + type NodesCoordinatorHelper interface + ComputeAdditionalLeaving func(allValidators []*state.ShardValidatorInfo) (map[uint32][]Validator, error) + GetChance func(uint32) uint32 + ValidatorsWeights func(validators []Validator) ([]uint32, error) + type NodesCoordinatorRegistry struct + CurrentEpoch uint32 + EpochsConfig map[string]*EpochValidators + type NodesSetup struct + Adaptivity bool + ChainID string + ConsensusGroupSize uint32 + Hysteresis float32 + InitialNodes []*InitialNode + MetaChainConsensusGroupSize uint32 + MetaChainMinNodes uint32 + MinNodesPerShard uint32 + MinTransactionVersion uint32 + RoundDuration uint64 + StartTime int64 + func NewNodesSetup(nodesFilePath string, addressPubkeyConverter core.PubkeyConverter, ...) (*NodesSetup, error) + func (ns *NodesSetup) AllInitialNodes() []GenesisNodeInfoHandler + func (ns *NodesSetup) GetAdaptivity() bool + func (ns *NodesSetup) GetChainId() string + func (ns *NodesSetup) GetHysteresis() float32 + func (ns *NodesSetup) GetMetaConsensusGroupSize() uint32 + func (ns *NodesSetup) GetMinTransactionVersion() uint32 + func (ns *NodesSetup) GetRoundDuration() uint64 + func (ns *NodesSetup) GetShardConsensusGroupSize() uint32 + func (ns *NodesSetup) GetShardIDForPubKey(pubKey []byte) (uint32, error) + func (ns *NodesSetup) GetStartTime() int64 + func (ns *NodesSetup) InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error) + func (ns *NodesSetup) InitialNodesInfo() (map[uint32][]GenesisNodeInfoHandler, map[uint32][]GenesisNodeInfoHandler) + func (ns *NodesSetup) InitialNodesInfoForShard(shardId uint32) ([]GenesisNodeInfoHandler, []GenesisNodeInfoHandler, error) + func (ns *NodesSetup) InitialNodesPubKeys() map[uint32][]string + func (ns *NodesSetup) IsInterfaceNil() bool + func (ns *NodesSetup) MinMetaHysteresisNodes() uint32 + func (ns *NodesSetup) MinNumberOfMetaNodes() uint32 + func (ns *NodesSetup) MinNumberOfNodes() uint32 + func (ns *NodesSetup) MinNumberOfNodesWithHysteresis() uint32 + func (ns *NodesSetup) MinNumberOfShardNodes() uint32 + func (ns *NodesSetup) MinShardHysteresisNodes() uint32 + func (ns *NodesSetup) NumberOfShards() uint32 + type NodesShuffler interface + IsInterfaceNil func() bool + UpdateNodeLists func(args ArgsUpdateNodes) (*ResUpdateNodes, error) + UpdateParams func(numNodesShard uint32, numNodesMeta uint32, hysteresis float32, adaptivity bool) + type NodesShufflerArgs struct + Adaptivity bool + BalanceWaitingListsEnableEpoch uint32 + Hysteresis float32 + MaxNodesEnableConfig []config.MaxNodesChangeConfig + NodesMeta uint32 + NodesShard uint32 + ShuffleBetweenShards bool + WaitingListFixEnableEpoch uint32 + type OneShardCoordinator struct + func (osc *OneShardCoordinator) CommunicationIdentifier(destShardID uint32) string + func (osc *OneShardCoordinator) ComputeId(_ []byte) uint32 + func (osc *OneShardCoordinator) IsInterfaceNil() bool + func (osc *OneShardCoordinator) NumberOfShards() uint32 + func (osc *OneShardCoordinator) SameShard(_, _ []byte) bool + func (osc *OneShardCoordinator) SelfId() uint32 + type PeerAccountListAndRatingHandler interface + ComputeDecreaseProposer func(shardId uint32, currentRating uint32, consecutiveMisses uint32) uint32 + ComputeDecreaseValidator func(shardId uint32, currentRating uint32) uint32 + ComputeIncreaseProposer func(shardId uint32, currentRating uint32) uint32 + ComputeIncreaseValidator func(shardId uint32, currentRating uint32) uint32 + GetChance func(uint32) uint32 + GetSignedBlocksThreshold func() float32 + GetStartRating func() uint32 + IsInterfaceNil func() bool + RevertIncreaseValidator func(shardId uint32, currentRating uint32, nrReverts uint32) uint32 + type PublicKeysSelector interface + GetAllEligibleValidatorsPublicKeys func(epoch uint32) (map[uint32][][]byte, error) + GetAllLeavingValidatorsPublicKeys func(epoch uint32) (map[uint32][][]byte, error) + GetAllWaitingValidatorsPublicKeys func(epoch uint32) (map[uint32][][]byte, error) + GetConsensusValidatorsPublicKeys func(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error) + GetOwnPublicKey func() []byte + GetValidatorsIndexes func(publicKeys []string, epoch uint32) ([]uint64, error) + type RandomSelector interface + IsInterfaceNil func() bool + Select func(randSeed []byte, sampleSize uint32) ([]uint32, error) + type ResUpdateNodes struct + Eligible map[uint32][]Validator + Leaving []Validator + StillRemaining []Validator + Waiting map[uint32][]Validator + type SelectionBasedProvider struct + func NewSelectionBasedProvider(hasher hashing.Hasher, maxSize uint32) *SelectionBasedProvider + func (sbp *SelectionBasedProvider) Get(randomness []byte, numValidators int64, expandedEligibleList []uint32) ([]uint32, error) + type SerializableValidator struct + Chances uint32 + Index uint32 + PubKey []byte + func ValidatorArrayToSerializableValidatorArray(validators []Validator) []*SerializableValidator + type ShuffledOutHandler interface + CurrentShardID func() uint32 + IsInterfaceNil func() bool + Process func(newShardID uint32) error + RegisterHandler func(handler func(newShardID uint32)) + type Validator interface + Chances func() uint32 + Index func() uint32 + PubKey func() []byte + Size func() int + func SerializableShardValidatorListToValidatorList(shardValidators []*SerializableValidator) ([]Validator, error) + type ValidatorsDistributor interface + DistributeValidators func(destination map[uint32][]Validator, source map[uint32][]Validator, rand []byte, ...) error + IsInterfaceNil func() bool