[sharding] set shardID within FindAccount

Signed-off-by: Leo Chen <leo@harmony.one>
pull/1207/head
Leo Chen 5 years ago
parent 9ea93d3dff
commit 3b54ec0420
  1. 13
      internal/configs/sharding/instance.go
  2. 2
      internal/configs/sharding/shardingconfig.go

@ -90,17 +90,20 @@ func (sc instance) FnAccounts() []genesis.DeployAccount {
return sc.fnAccounts
}
// FindAccount returns the deploy account based on the blskey
func (sc instance) FindAccount(blsPubKey string) (int, *genesis.DeployAccount) {
// FindAccount returns the deploy account based on the blskey, and if the account is a leader
// or not in the bootstrapping process.
func (sc instance) FindAccount(blsPubKey string) (bool, *genesis.DeployAccount) {
for i, item := range sc.hmyAccounts {
if item.BlsPublicKey == blsPubKey {
return i, &item
item.ShardID = uint32(i) % sc.numShards
return uint32(i) < sc.numShards, &item
}
}
for i, item := range sc.fnAccounts {
if item.BlsPublicKey == blsPubKey {
return i + int(sc.numShards), &item
item.ShardID = uint32(i) % sc.numShards
return false, &item
}
}
return -1, nil
return false, nil
}

@ -33,5 +33,5 @@ type Instance interface {
FnAccounts() []genesis.DeployAccount
// FindAccount returns the deploy account based on the blskey
FindAccount(blsPubKey string) (int, *genesis.DeployAccount)
FindAccount(blsPubKey string) (bool, *genesis.DeployAccount)
}

Loading…
Cancel
Save