[committee] Fix too much hmy node assignment mistake (#1994)

pull/1999/head
Edgar Aroutiounian 5 years ago committed by GitHub
parent b805726db6
commit dd5e1f1634
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      shard/committee/assignment.go

@ -163,27 +163,25 @@ func eposStakedCommittee(
} }
shardCount := int(s.NumShards()) shardCount := int(s.NumShards())
shardState := &shard.State{} shardState := &shard.State{}
shardState.Shards = make([]shard.Committee, shardCount) shardState.Shards = make([]shard.Committee, shardCount)
hAccounts := s.HmyAccounts() hAccounts := s.HmyAccounts()
shardHarmonyNodes := s.NumHarmonyOperatedNodesPerShard()
// Shard state needs to be sorted by shard ID
for i := 0; i < shardCount; i++ { for i := 0; i < shardCount; i++ {
shardState.Shards[i] = shard.Committee{uint32(i), shard.SlotList{}} shardState.Shards[i] = shard.Committee{uint32(i), shard.SlotList{}}
} for j := 0; j < shardHarmonyNodes; j++ {
index := i + j*shardCount
for i := range hAccounts { pub := &bls.PublicKey{}
shardID := i % shardCount pub.DeserializeHexStr(hAccounts[index].BlsPublicKey)
pub := &bls.PublicKey{} pubKey := shard.BlsPublicKey{}
pub.DeserializeHexStr(hAccounts[i].BlsPublicKey) pubKey.FromLibBLSPublicKey(pub)
pubKey := shard.BlsPublicKey{} shardState.Shards[i].Slots = append(shardState.Shards[i].Slots, shard.Slot{
pubKey.FromLibBLSPublicKey(pub) common2.ParseAddr(hAccounts[index].Address),
shardState.Shards[shardID].Slots = append(shardState.Shards[shardID].Slots, shard.Slot{ pubKey,
common2.ParseAddr(hAccounts[i].Address), nil,
pubKey, })
nil, }
})
} }
if stakedSlotsCount == 0 { if stakedSlotsCount == 0 {

Loading…
Cancel
Save