Documentation ¶
Index ¶
- Variables
- 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
- type ArgsUpdateNodes
- type Cacher
- type ChanceComputer
- type Coordinator
- type CrossShardValidatorDistributor
- type EpochHandler
- type EpochStartActionHandler
- type EpochStartEventNotifier
- type EpochValidators
- type GenesisNodeInfoHandler
- type GenesisNodesSetupHandler
- type InitialNode
- type IntraShardValidatorDistributor
- type NodeTypeProviderHandler
- type NodesCoordinator
- type NodesCoordinatorHelper
- type NodesCoordinatorRegistry
- type NodesSetup
- func (ns *NodesSetup) AllInitialNodes() []GenesisNodeInfoHandler
- func (ns *NodesSetup) GetAdaptivity() bool
- func (ns *NodesSetup) GetHysteresis() float32
- func (ns *NodesSetup) GetMetaConsensusGroupSize() 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
- type NodesShufflerArgs
- type OneShardCoordinator
- 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
- type PublicKeysSelector
- type RandomSelector
- type ResUpdateNodes
- type SelectionBasedProvider
- type SerializableValidator
- type ShuffledOutHandler
- type Validator
- type ValidatorsDistributor
Constants ¶
This section is empty.
Variables ¶
var ErrCouldNotParseAddress = errors.New("could not parse node's address")
ErrCouldNotParseAddress signals that a given address could not be parsed
var ErrCouldNotParsePubKey = errors.New("could not parse node's public key")
ErrCouldNotParsePubKey signals that a given public key could not be parsed
var ErrEpochNodesConfigDoesNotExist = errors.New("epoch nodes configuration does not exist")
ErrEpochNodesConfigDoesNotExist signals that the epoch nodes configuration is missing
var ErrInvalidConsensusGroupSize = errors.New("invalid consensus group size")
ErrInvalidConsensusGroupSize signals that the consensus size is invalid (e.g. value is negative)
var ErrInvalidMaximumNumberOfShards = errors.New("trying to set an invalid maximum number of shards")
ErrInvalidMaximumNumberOfShards signals that an invalid maximum number of shards has been provided
var ErrInvalidNumberOfShards = errors.New("the number of shards must be greater than zero")
ErrInvalidNumberOfShards signals that an invalid number of shards was passed to the sharding registry
var ErrInvalidNumberPubKeys = errors.New("invalid number of public keys")
ErrInvalidNumberPubKeys signals that an invalid number of public keys was used
var ErrInvalidSampleSize = errors.New("invalid sample size")
ErrInvalidSampleSize signals that an invalid sample size was provided
var ErrInvalidShardId = errors.New("shard id must be smaller than the total number of shards")
ErrInvalidShardId signals that an invalid shard is was passed
var ErrInvalidWeight = errors.New("invalid weight")
ErrInvalidWeight signals an invalid weight was provided
var ErrMapSizeZero = errors.New("map size zero")
ErrMapSizeZero signals that there are no elements in the map
var ErrMinNodesPerShardSmallerThanConsensusSize = errors.New("minimum nodes per shard is smaller than consensus group size")
ErrMinNodesPerShardSmallerThanConsensusSize signals that an invalid min nodes per shard has been provided
var ErrNegativeOrZeroConsensusGroupSize = errors.New("negative or zero consensus group size")
ErrNegativeOrZeroConsensusGroupSize signals that an invalid consensus group size has been provided
var ErrNilBlockBody = errors.New("nil block body")
ErrNilBlockBody signals that block body is nil
var ErrNilBootStorer = errors.New("nil boot storer provided")
ErrNilBootStorer signals that a nil boot storer was provided
var ErrNilCacher = errors.New("nil cacher")
ErrNilCacher signals that a nil cacher has been provided
var ErrNilChanceComputer = errors.New("nil chance computer")
ErrNilChanceComputer signals that a nil chance computer was provided
var ErrNilEndOfProcessingHandler = errors.New("nil end of processing handler")
ErrNilEndOfProcessingHandler signals that a nil end of processing handler has been provided
var ErrNilEpochNotifier = errors.New("nil epoch notifier")
ErrNilEpochNotifier signals that the provided epoch notifier is nil
var ErrNilHasher = errors.New("nil hasher")
ErrNilHasher signals that a nil hasher has been provided
var ErrNilInputNodesMap = errors.New("nil input nodes map")
ErrNilInputNodesMap signals that a nil nodes map was provided
var ErrNilMarshalizer = errors.New("nil marshalizer")
ErrNilMarshalizer signals that the marshalizer is nil
var ErrNilNodeShufflerArguments = errors.New("nil arguments for the creation of a node shuffler")
ErrNilNodeShufflerArguments signals that a nil argument pointer was provided for creating the nodes shuffler instance
var ErrNilNodeStopChannel = errors.New("nil node stop channel")
ErrNilNodeStopChannel signals that a nil node stop channel has been provided
var ErrNilNodeTypeProvider = errors.New("nil node type provider")
ErrNilNodeTypeProvider signals that a nil node type provider has been given
var ErrNilNodesCoordinator = errors.New("nil nodesCoordinator")
ErrNilNodesCoordinator signals that the nodesCoordinator is nil
var ErrNilOrEmptyDestinationForDistribute = errors.New("nil or empty destination list for distributeNodes")
ErrNilOrEmptyDestinationForDistribute signals that a nil or empty value was provided for destination of distributedNodes
var ErrNilOwnPublicKey = errors.New("nil own public key")
ErrNilOwnPublicKey signals that a nil own public key has been provided
var ErrNilPreviousEpochConfig = errors.New("nil previous epoch config")
ErrNilPreviousEpochConfig signals that the previous epoch config is nil
var ErrNilPubKey = errors.New("nil public key")
ErrNilPubKey signals that the public key is nil
var ErrNilPubkeyConverter = errors.New("trying to set nil pubkey converter")
ErrNilPubkeyConverter signals that a nil public key converter has been provided
var ErrNilRandomSelector = errors.New("nil selector")
ErrNilRandomSelector signals that a nil selector was provided
var ErrNilRandomness = errors.New("nil randomness source")
ErrNilRandomness signals that a nil randomness source has been provided
var ErrNilShardCoordinator = errors.New("trying to set nil shard coordinator")
ErrNilShardCoordinator signals that a nil shard coordinator has been provided
var ErrNilShuffledOutHandler = errors.New("nil shuffled out handler")
ErrNilShuffledOutHandler signals that a nil shuffled out handler has been provided
var ErrNilShuffler = errors.New("nil nodes shuffler provided")
ErrNilShuffler signals that a nil shuffler was provided
var ErrNilWeights = errors.New("nil weights")
ErrNilWeights signals that nil weights list was provided
var ErrNoPubKeys = errors.New("no public keys defined")
ErrNoPubKeys signals an error when public keys are missing
var ErrNodesSizeSmallerThanMinNoOfNodes = errors.New("length of nodes defined is smaller than min nodes per shard required")
ErrNodesSizeSmallerThanMinNoOfNodes signals that there are not enough nodes defined in genesis file
var ErrNotImplemented = errors.New("feature not implemented")
ErrNotImplemented signals a call of a non implemented functionality
var ErrPublicKeyNotFoundInGenesis = errors.New("public key is not valid, it is missing from genesis file")
ErrPublicKeyNotFoundInGenesis signals an error when the public key is not in genesis file
var ErrShardIdOutOfRange = errors.New("shard id out of range")
ErrShardIdOutOfRange signals an error when shard id is out of range
var ErrSmallMetachainEligibleListSize = errors.New("small metachain eligible list size")
ErrSmallMetachainEligibleListSize signals that the eligible validators list's size is less than the consensus size
var ErrSmallShardEligibleListSize = errors.New("small shard eligible list size")
ErrSmallShardEligibleListSize signals that the eligible validators list's size is less than the consensus size
var ErrValidatorCannotBeFullArchive = errors.New("validator cannot be a full archive node")
ErrValidatorCannotBeFullArchive signals a configuration issue because a validator cannot be a full archive node
var ErrValidatorNotFound = errors.New("validator not found")
ErrValidatorNotFound signals that the validator has not been found
var ErrWrongTypeAssertion = errors.New("wrong type assertion")
ErrWrongTypeAssertion signals wrong type assertion error
Functions ¶
func NewHashValidatorsShuffler ¶ added in v1.0.129
func NewHashValidatorsShuffler(args *NodesShufflerArgs) (*randHashShuffler, error)
NewHashValidatorsShuffler creates a validator shuffler that uses a hash between validator key and a given random number to do the shuffling
func NewIndexHashedNodesCoordinator ¶
func NewIndexHashedNodesCoordinator(arguments ArgNodesCoordinator) (*indexHashedNodesCoordinator, error)
NewIndexHashedNodesCoordinator creates a new index hashed group selector
func NewIndexHashedNodesCoordinatorWithRater ¶
func NewIndexHashedNodesCoordinatorWithRater( indexNodesCoordinator *indexHashedNodesCoordinator, chanceComputer ChanceComputer, ) (*indexHashedNodesCoordinatorWithRater, error)
NewIndexHashedNodesCoordinatorWithRater creates a new index hashed group selector
func NewMultiShardCoordinator ¶
NewMultiShardCoordinator returns a new multiShardCoordinator and initializes the masks
func NewSelectorExpandedList ¶ added in v0.0.5
func NewSelectorExpandedList(weightList []uint32, hasher hashing.Hasher) (*selectorExpandedList, error)
NewSelectorExpandedList creates a new selector initializing selection set to the given lists of validators and expanding it according to each validator weight.
func NewSelectorWRS ¶ added in v0.0.5
NewSelectorWRS creates a new selector initializing selection set to the given lists of weights
func NewShuffledOutTrigger ¶ added in v1.0.103
func NewShuffledOutTrigger( ownPubKey []byte, currentShardID uint32, endProcessHandler func(argument endProcess.ArgEndProcess) error, ) (*shuffledOutTrigger, error)
NewShuffledOutTrigger returns a new instance of shuffledOutTrigger
func NewValidator ¶
NewValidator creates a new instance of a validator
func NodesInfoToValidators ¶ added in v1.0.102
func NodesInfoToValidators(nodesInfo map[uint32][]GenesisNodeInfoHandler) (map[uint32][]Validator, error)
NodesInfoToValidators maps nodeInfo to validator interface
func SerializableValidatorsToValidators ¶ added in v1.0.111
func SerializableValidatorsToValidators(nodeRegistryValidators map[string][]*SerializableValidator) (map[uint32][]Validator, error)
SerializableValidatorsToValidators creates the validator map from serializable validator map
Types ¶
type ArgNodesCoordinator ¶
type ArgNodesCoordinator struct { ShardConsensusGroupSize int MetaConsensusGroupSize int Marshalizer marshal.Marshalizer Hasher hashing.Hasher Shuffler NodesShuffler EpochStartNotifier EpochStartEventNotifier BootStorer storage.Storer ShardIDAsObserver uint32 NbShards uint32 EligibleNodes map[uint32][]Validator WaitingNodes map[uint32][]Validator SelfPublicKey []byte Epoch uint32 StartEpoch uint32 ConsensusGroupCache Cacher ShuffledOutHandler ShuffledOutHandler WaitingListFixEnabledEpoch uint32 ChanStopNode chan endProcess.ArgEndProcess NodeTypeProvider NodeTypeProviderHandler IsFullArchive bool }
ArgNodesCoordinator holds all dependencies required by the nodes coordinator in order to create new instances
type ArgsUpdateNodes ¶
type ArgsUpdateNodes struct { Eligible map[uint32][]Validator Waiting map[uint32][]Validator NewNodes []Validator UnStakeLeaving []Validator AdditionalLeaving []Validator Rand []byte NbShards uint32 Epoch uint32 }
ArgsUpdateNodes holds the parameters required by the shuffler to generate a new nodes configuration
type Cacher ¶
type Cacher interface { // Clear is used to completely clear the cache. Clear() // Put adds a value to the cache. Returns true if an eviction occurred. Put(key []byte, value interface{}, sizeInBytes int) (evicted bool) // Get looks up a key's value from the cache. Get(key []byte) (value interface{}, ok bool) }
Cacher provides the capabilities needed to store and retrieve information needed in the NodesCoordinator
type ChanceComputer ¶
type ChanceComputer interface { //GetChance returns the chances for the the rating GetChance(uint32) uint32 //IsInterfaceNil verifies if the interface is nil IsInterfaceNil() bool }
ChanceComputer provides chance computation capabilities based on a rating
type Coordinator ¶
type Coordinator interface { NumberOfShards() uint32 ComputeId(address []byte) uint32 SelfId() uint32 SameShard(firstAddress, secondAddress []byte) bool CommunicationIdentifier(destShardID uint32) string IsInterfaceNil() bool }
Coordinator defines what a shard state coordinator should hold
type CrossShardValidatorDistributor ¶ added in v1.0.115
type CrossShardValidatorDistributor struct{}
CrossShardValidatorDistributor - distributes validators from source to destination cross shards
func (*CrossShardValidatorDistributor) DistributeValidators ¶ added in v1.0.115
func (vd *CrossShardValidatorDistributor) DistributeValidators( destination map[uint32][]Validator, source map[uint32][]Validator, rand []byte, balanced bool, ) error
DistributeValidators will handle the moving of the nodes to the map for cross shard validator distributor
func (*CrossShardValidatorDistributor) IsInterfaceNil ¶ added in v1.0.115
func (vd *CrossShardValidatorDistributor) IsInterfaceNil() bool
IsInterfaceNil - verifies if the interface is nil
type EpochHandler ¶
EpochHandler defines what a component which handles current epoch should be able to do
type EpochStartActionHandler ¶ added in v1.0.102
type EpochStartActionHandler interface { EpochStartAction(hdr data.HeaderHandler) EpochStartPrepare(metaHdr data.HeaderHandler, body data.BodyHandler) NotifyOrder() uint32 }
EpochStartActionHandler defines the action taken on epoch start event
type EpochStartEventNotifier ¶ added in v1.0.102
type EpochStartEventNotifier interface { RegisterHandler(handler epochStart.ActionHandler) UnregisterHandler(handler epochStart.ActionHandler) IsInterfaceNil() bool }
EpochStartEventNotifier provides Register and Unregister functionality for the end of epoch events
type EpochValidators ¶
type EpochValidators struct { EligibleValidators map[string][]*SerializableValidator `json:"eligibleValidators"` WaitingValidators map[string][]*SerializableValidator `json:"waitingValidators"` LeavingValidators map[string][]*SerializableValidator `json:"leavingValidators"` }
EpochValidators holds one epoch configuration for a nodes coordinator
type GenesisNodeInfoHandler ¶ added in v1.0.102
type GenesisNodeInfoHandler interface { AssignedShard() uint32 AddressBytes() []byte PubKeyBytes() []byte GetInitialRating() uint32 IsInterfaceNil() bool }
GenesisNodeInfoHandler defines the public methods for the genesis nodes info
type GenesisNodesSetupHandler ¶ added in v1.0.102
type GenesisNodesSetupHandler interface { AllInitialNodes() []GenesisNodeInfoHandler InitialNodesPubKeys() map[uint32][]string GetShardIDForPubKey(pubkey []byte) (uint32, error) InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error) InitialNodesInfoForShard(shardId uint32) ([]GenesisNodeInfoHandler, []GenesisNodeInfoHandler, error) InitialNodesInfo() (map[uint32][]GenesisNodeInfoHandler, map[uint32][]GenesisNodeInfoHandler) GetStartTime() int64 GetRoundDuration() uint64 GetShardConsensusGroupSize() uint32 GetMetaConsensusGroupSize() uint32 NumberOfShards() uint32 MinNumberOfNodes() uint32 MinNumberOfShardNodes() uint32 MinNumberOfMetaNodes() uint32 GetHysteresis() float32 GetAdaptivity() bool MinNumberOfNodesWithHysteresis() uint32 IsInterfaceNil() bool }
GenesisNodesSetupHandler returns the genesis nodes info
type InitialNode ¶
type InitialNode struct { PubKey string `json:"pubkey"` Address string `json:"address"` InitialRating uint32 `json:"initialRating"` // contains filtered or unexported fields }
InitialNode holds data from json
func (*InitialNode) AddressBytes ¶ added in v1.2.0
func (ni *InitialNode) AddressBytes() []byte
AddressBytes gets the node address as bytes
func (*InitialNode) AssignedShard ¶ added in v1.2.0
func (ni *InitialNode) AssignedShard() uint32
AssignedShard gets the node assigned shard
func (*InitialNode) GetInitialRating ¶ added in v1.2.0
func (ni *InitialNode) GetInitialRating() uint32
GetInitialRating gets the initial rating for a node
func (*InitialNode) IsInterfaceNil ¶ added in v1.2.0
func (ni *InitialNode) IsInterfaceNil() bool
IsInterfaceNil returns true if underlying object is nil
func (*InitialNode) PubKeyBytes ¶ added in v1.2.0
func (ni *InitialNode) PubKeyBytes() []byte
PubKeyBytes gets the node public key as bytes
type IntraShardValidatorDistributor ¶ added in v1.0.115
type IntraShardValidatorDistributor struct{}
IntraShardValidatorDistributor - distributes validators from source to destination inside the same shard
func (*IntraShardValidatorDistributor) DistributeValidators ¶ added in v1.0.115
func (vd *IntraShardValidatorDistributor) DistributeValidators( destination map[uint32][]Validator, source map[uint32][]Validator, _ []byte, _ bool, ) error
DistributeValidators will handle the moving of the nodes to the map for intra shard validator distributor
func (*IntraShardValidatorDistributor) IsInterfaceNil ¶ added in v1.0.115
func (vd *IntraShardValidatorDistributor) IsInterfaceNil() bool
IsInterfaceNil - verifies if the interface is nil
type NodeTypeProviderHandler ¶ added in v1.2.4
type NodeTypeProviderHandler interface { SetType(nodeType core.NodeType) GetType() core.NodeType IsInterfaceNil() bool }
NodeTypeProviderHandler defines the actions needed for a component that can handle the node type
type NodesCoordinator ¶
type NodesCoordinator interface { NodesCoordinatorHelper PublicKeysSelector ComputeConsensusGroup(randomness []byte, round uint64, shardId uint32, epoch uint32) (validatorsGroup []Validator, err error) GetValidatorWithPublicKey(publicKey []byte) (validator Validator, shardId uint32, err error) LoadState(key []byte) error GetSavedStateKey() []byte ShardIdForEpoch(epoch uint32) (uint32, error) ShuffleOutForEpoch(_ uint32) GetConsensusWhitelistedNodes(epoch uint32) (map[string]struct{}, error) ConsensusGroupSize(uint32) int GetNumTotalEligible() uint64 IsInterfaceNil() bool }
NodesCoordinator defines the behaviour of a struct able to do validator group selection
type NodesCoordinatorHelper ¶ added in v0.0.5
type NodesCoordinatorHelper interface { ValidatorsWeights(validators []Validator) ([]uint32, error) ComputeAdditionalLeaving(allValidators []*state.ShardValidatorInfo) (map[uint32][]Validator, error) GetChance(uint32) uint32 }
NodesCoordinatorHelper provides polymorphism functionality for nodesCoordinator
type NodesCoordinatorRegistry ¶
type NodesCoordinatorRegistry struct { EpochsConfig map[string]*EpochValidators `json:"epochConfigs"` CurrentEpoch uint32 `json:"currentEpoch"` }
NodesCoordinatorRegistry holds the data that can be used to initialize a nodes coordinator
type NodesSetup ¶
type NodesSetup struct { StartTime int64 `json:"startTime"` RoundDuration uint64 `json:"roundDuration"` ConsensusGroupSize uint32 `json:"consensusGroupSize"` MinNodesPerShard uint32 `json:"minNodesPerShard"` MetaChainConsensusGroupSize uint32 `json:"metaChainConsensusGroupSize"` MetaChainMinNodes uint32 `json:"metaChainMinNodes"` Hysteresis float32 `json:"hysteresis"` Adaptivity bool `json:"adaptivity"` InitialNodes []*InitialNode `json:"initialNodes"` // contains filtered or unexported fields }
NodesSetup hold data for decoded data from json file
func NewNodesSetup ¶
func NewNodesSetup( nodesFilePath string, addressPubkeyConverter core.PubkeyConverter, validatorPubkeyConverter core.PubkeyConverter, genesisMaxNumShards uint32, ) (*NodesSetup, error)
NewNodesSetup creates a new decoded nodes structure from json config file
func (*NodesSetup) AllInitialNodes ¶ added in v1.0.115
func (ns *NodesSetup) AllInitialNodes() []GenesisNodeInfoHandler
AllInitialNodes returns all initial nodes loaded
func (*NodesSetup) GetAdaptivity ¶ added in v1.0.149
func (ns *NodesSetup) GetAdaptivity() bool
GetAdaptivity returns the value of the adaptivity boolean flag
func (*NodesSetup) GetHysteresis ¶ added in v1.0.149
func (ns *NodesSetup) GetHysteresis() float32
GetHysteresis returns the hysteresis value
func (*NodesSetup) GetMetaConsensusGroupSize ¶ added in v1.0.102
func (ns *NodesSetup) GetMetaConsensusGroupSize() uint32
GetMetaConsensusGroupSize returns the metachain consensus group size
func (*NodesSetup) GetRoundDuration ¶ added in v1.0.102
func (ns *NodesSetup) GetRoundDuration() uint64
GetRoundDuration returns the round duration
func (*NodesSetup) GetShardConsensusGroupSize ¶ added in v1.0.102
func (ns *NodesSetup) GetShardConsensusGroupSize() uint32
GetShardConsensusGroupSize returns the shard consensus group size
func (*NodesSetup) GetShardIDForPubKey ¶
func (ns *NodesSetup) GetShardIDForPubKey(pubKey []byte) (uint32, error)
GetShardIDForPubKey returns the allocated shard ID from public key
func (*NodesSetup) GetStartTime ¶ added in v1.0.102
func (ns *NodesSetup) GetStartTime() int64
GetStartTime returns the start time
func (*NodesSetup) InitialEligibleNodesPubKeysForShard ¶
func (ns *NodesSetup) InitialEligibleNodesPubKeysForShard(shardId uint32) ([]string, error)
InitialEligibleNodesPubKeysForShard - gets initial nodes public keys for shard
func (*NodesSetup) InitialNodesInfo ¶
func (ns *NodesSetup) InitialNodesInfo() (map[uint32][]GenesisNodeInfoHandler, map[uint32][]GenesisNodeInfoHandler)
InitialNodesInfo - gets initial nodes info
func (*NodesSetup) InitialNodesInfoForShard ¶
func (ns *NodesSetup) InitialNodesInfoForShard(shardId uint32) ([]GenesisNodeInfoHandler, []GenesisNodeInfoHandler, error)
InitialNodesInfoForShard - gets initial nodes info for shard
func (*NodesSetup) InitialNodesPubKeys ¶
func (ns *NodesSetup) InitialNodesPubKeys() map[uint32][]string
InitialNodesPubKeys - gets initial nodes public keys
func (*NodesSetup) IsInterfaceNil ¶ added in v1.0.102
func (ns *NodesSetup) IsInterfaceNil() bool
IsInterfaceNil returns true if underlying object is nil
func (*NodesSetup) MinMetaHysteresisNodes ¶ added in v1.1.3
func (ns *NodesSetup) MinMetaHysteresisNodes() uint32
MinMetaHysteresisNodes returns the minimum number of hysteresis nodes in metachain
func (*NodesSetup) MinNumberOfMetaNodes ¶ added in v1.0.149
func (ns *NodesSetup) MinNumberOfMetaNodes() uint32
MinNumberOfMetaNodes returns the minimum number of nodes in metachain
func (*NodesSetup) MinNumberOfNodes ¶ added in v1.0.110
func (ns *NodesSetup) MinNumberOfNodes() uint32
MinNumberOfNodes returns the minimum number of nodes
func (*NodesSetup) MinNumberOfNodesWithHysteresis ¶ added in v1.1.3
func (ns *NodesSetup) MinNumberOfNodesWithHysteresis() uint32
MinNumberOfNodesWithHysteresis returns the minimum number of nodes with hysteresis
func (*NodesSetup) MinNumberOfShardNodes ¶ added in v1.0.149
func (ns *NodesSetup) MinNumberOfShardNodes() uint32
MinNumberOfShardNodes returns the minimum number of nodes per shard
func (*NodesSetup) MinShardHysteresisNodes ¶ added in v1.1.3
func (ns *NodesSetup) MinShardHysteresisNodes() uint32
MinShardHysteresisNodes returns the minimum number of hysteresis nodes per shard
func (*NodesSetup) NumberOfShards ¶
func (ns *NodesSetup) NumberOfShards() uint32
NumberOfShards returns the calculated number of shards
type NodesShuffler ¶
type NodesShuffler interface { UpdateParams(numNodesShard uint32, numNodesMeta uint32, hysteresis float32, adaptivity bool) UpdateNodeLists(args ArgsUpdateNodes) (*ResUpdateNodes, error) IsInterfaceNil() bool }
NodesShuffler provides shuffling functionality for nodes
type NodesShufflerArgs ¶ added in v1.1.15
type NodesShufflerArgs struct { NodesShard uint32 NodesMeta uint32 Hysteresis float32 Adaptivity bool ShuffleBetweenShards bool MaxNodesEnableConfig []config.MaxNodesChangeConfig BalanceWaitingListsEnableEpoch uint32 WaitingListFixEnableEpoch uint32 }
NodesShufflerArgs defines the arguments required to create a nodes shuffler
type OneShardCoordinator ¶
type OneShardCoordinator struct{}
OneShardCoordinator creates a shard coordinator object
func (*OneShardCoordinator) CommunicationIdentifier ¶
func (osc *OneShardCoordinator) CommunicationIdentifier(destShardID uint32) string
CommunicationIdentifier returns the identifier between current shard ID and destination shard ID for this implementation, it will always return "_0" as there is a single shard
func (*OneShardCoordinator) ComputeId ¶
func (osc *OneShardCoordinator) ComputeId(_ []byte) uint32
ComputeId gets shard for the given address
func (*OneShardCoordinator) IsInterfaceNil ¶
func (osc *OneShardCoordinator) IsInterfaceNil() bool
IsInterfaceNil returns true if there is no value under the interface
func (*OneShardCoordinator) NumberOfShards ¶
func (osc *OneShardCoordinator) NumberOfShards() uint32
NumberOfShards gets number of shards
func (*OneShardCoordinator) SameShard ¶
func (osc *OneShardCoordinator) SameShard(_, _ []byte) bool
SameShard returns weather two addresses belong to the same shard
func (*OneShardCoordinator) SelfId ¶
func (osc *OneShardCoordinator) SelfId() uint32
SelfId gets shard of the current node
type PeerAccountListAndRatingHandler ¶ added in v1.0.102
type PeerAccountListAndRatingHandler interface { //GetChance returns the chances for the the rating GetChance(uint32) uint32 //GetStartRating gets the start rating values GetStartRating() uint32 //GetSignedBlocksThreshold gets the threshold for the minimum signed blocks GetSignedBlocksThreshold() float32 //ComputeIncreaseProposer computes the new rating for the increaseLeader ComputeIncreaseProposer(shardId uint32, currentRating uint32) uint32 //ComputeDecreaseProposer computes the new rating for the decreaseLeader ComputeDecreaseProposer(shardId uint32, currentRating uint32, consecutiveMisses uint32) uint32 //RevertIncreaseValidator computes the new rating if a revert for increaseProposer should be done RevertIncreaseValidator(shardId uint32, currentRating uint32, nrReverts uint32) uint32 //ComputeIncreaseValidator computes the new rating for the increaseValidator ComputeIncreaseValidator(shardId uint32, currentRating uint32) uint32 //ComputeDecreaseValidator computes the new rating for the decreaseValidator ComputeDecreaseValidator(shardId uint32, currentRating uint32) uint32 //IsInterfaceNil verifies if the interface is nil IsInterfaceNil() bool }
PeerAccountListAndRatingHandler provides Rating Computation Capabilites for the Nodes Coordinator and ValidatorStatistics
type PublicKeysSelector ¶
type PublicKeysSelector interface { GetValidatorsIndexes(publicKeys []string, epoch uint32) ([]uint64, error) GetAllEligibleValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetAllWaitingValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetAllLeavingValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) GetConsensusValidatorsPublicKeys(randomness []byte, round uint64, shardId uint32, epoch uint32) ([]string, error) GetOwnPublicKey() []byte }
PublicKeysSelector allows retrieval of eligible validators public keys
type RandomSelector ¶ added in v0.0.5
type RandomSelector interface { Select(randSeed []byte, sampleSize uint32) ([]uint32, error) IsInterfaceNil() bool }
RandomSelector selects randomly a subset of elements from a set of data
type ResUpdateNodes ¶ added in v1.0.110
type ResUpdateNodes struct { Eligible map[uint32][]Validator Waiting map[uint32][]Validator Leaving []Validator StillRemaining []Validator }
ResUpdateNodes holds the result of the UpdateNodes method
type SelectionBasedProvider ¶
type SelectionBasedProvider struct {
// contains filtered or unexported fields
}
SelectionBasedProvider will handle the returning of the consensus group by simulating a reslicing of the expanded eligible list. A comparison between a real reslicing and this can be found in common_test.go
func NewSelectionBasedProvider ¶
func NewSelectionBasedProvider(hasher hashing.Hasher, maxSize uint32) *SelectionBasedProvider
NewSelectionBasedProvider will return a new instance of SelectionBasedProvider
func (*SelectionBasedProvider) Get ¶
func (sbp *SelectionBasedProvider) Get(randomness []byte, numValidators int64, expandedEligibleList []uint32) ([]uint32, error)
Get will return the consensus group based on the randomness. After an item is chosen, it is added to the slice so it won't be selected again so next time a new item is needed, the index is recalculated until the validator doesn't exist in that slice
type SerializableValidator ¶
type SerializableValidator struct { PubKey []byte `json:"pubKey"` Chances uint32 `json:"chances"` Index uint32 `json:"index"` }
SerializableValidator holds the minimal data required for marshalling and un-marshalling a validator
func ValidatorArrayToSerializableValidatorArray ¶ added in v1.0.102
func ValidatorArrayToSerializableValidatorArray(validators []Validator) []*SerializableValidator
ValidatorArrayToSerializableValidatorArray -
type ShuffledOutHandler ¶ added in v1.0.103
type ShuffledOutHandler interface { Process(newShardID uint32) error RegisterHandler(handler func(newShardID uint32)) CurrentShardID() uint32 IsInterfaceNil() bool }
ShuffledOutHandler defines the methods needed for the computation of a shuffled out event
type Validator ¶
Validator defines a node that can be allocated to a shard for participation in a consensus group as validator or block proposer
func SerializableShardValidatorListToValidatorList ¶ added in v1.0.111
func SerializableShardValidatorListToValidatorList(shardValidators []*SerializableValidator) ([]Validator, error)
SerializableShardValidatorListToValidatorList creates the validator list from serializable validator list
Source Files ¶
- common.go
- errors.go
- expandedListSampling.go
- hashValidatorShuffler.go
- indexHashedNodesCoordinator.go
- indexHashedNodesCoordinatorRegistry.go
- indexHashedNodesCoordinatorWithRater.go
- interface.go
- multiShardCoordinator.go
- nodesSetup.go
- oneShardCoordinator.go
- selectionBasedProvider.go
- shardingArgs.go
- shuffledOutTrigger.go
- validator.go
- validatorDistributor.go
- weightedRandomSampling.go