/
validatorDistributor.go
42 lines (35 loc) · 1.37 KB
/
validatorDistributor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package nodesCoordinator
// IntraShardValidatorDistributor - distributes validators from source to destination inside the same shard
type IntraShardValidatorDistributor struct{}
// DistributeValidators will handle the moving of the nodes to the map for intra shard validator distributor
func (vd *IntraShardValidatorDistributor) DistributeValidators(
destination map[uint32][]Validator,
source map[uint32][]Validator,
_ []byte,
_ bool,
) error {
return moveNodesToMap(destination, source)
}
// IsInterfaceNil - verifies if the interface is nil
func (vd *IntraShardValidatorDistributor) IsInterfaceNil() bool {
return vd == nil
}
// CrossShardValidatorDistributor - distributes validators from source to destination cross shards
type CrossShardValidatorDistributor struct{}
// DistributeValidators will handle the moving of the nodes to the map for cross shard validator distributor
func (vd *CrossShardValidatorDistributor) DistributeValidators(
destination map[uint32][]Validator,
source map[uint32][]Validator,
rand []byte,
balanced bool,
) error {
allValidators := make([]Validator, 0)
for _, list := range source {
allValidators = append(allValidators, list...)
}
return distributeValidators(destination, allValidators, rand, balanced)
}
// IsInterfaceNil - verifies if the interface is nil
func (vd *CrossShardValidatorDistributor) IsInterfaceNil() bool {
return vd == nil
}