|
|
@ -1,6 +1,8 @@ |
|
|
|
package shardingconfig |
|
|
|
package shardingconfig |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"math/big" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/harmony-one/harmony/internal/ctxerror" |
|
|
|
"github.com/harmony-one/harmony/internal/ctxerror" |
|
|
|
"github.com/harmony-one/harmony/internal/genesis" |
|
|
|
"github.com/harmony-one/harmony/internal/genesis" |
|
|
|
) |
|
|
|
) |
|
|
@ -11,6 +13,7 @@ type instance struct { |
|
|
|
numHarmonyOperatedNodesPerShard int |
|
|
|
numHarmonyOperatedNodesPerShard int |
|
|
|
hmyAccounts []genesis.DeployAccount |
|
|
|
hmyAccounts []genesis.DeployAccount |
|
|
|
fnAccounts []genesis.DeployAccount |
|
|
|
fnAccounts []genesis.DeployAccount |
|
|
|
|
|
|
|
reshardingEpoch []*big.Int |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewInstance creates and validates a new sharding configuration based
|
|
|
|
// NewInstance creates and validates a new sharding configuration based
|
|
|
@ -19,6 +22,7 @@ func NewInstance( |
|
|
|
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int, |
|
|
|
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int, |
|
|
|
hmyAccounts []genesis.DeployAccount, |
|
|
|
hmyAccounts []genesis.DeployAccount, |
|
|
|
fnAccounts []genesis.DeployAccount, |
|
|
|
fnAccounts []genesis.DeployAccount, |
|
|
|
|
|
|
|
reshardingEpoch []*big.Int, |
|
|
|
) (Instance, error) { |
|
|
|
) (Instance, error) { |
|
|
|
if numShards < 1 { |
|
|
|
if numShards < 1 { |
|
|
|
return nil, ctxerror.New("sharding config must have at least one shard", |
|
|
|
return nil, ctxerror.New("sharding config must have at least one shard", |
|
|
@ -45,6 +49,7 @@ func NewInstance( |
|
|
|
numHarmonyOperatedNodesPerShard: numHarmonyOperatedNodesPerShard, |
|
|
|
numHarmonyOperatedNodesPerShard: numHarmonyOperatedNodesPerShard, |
|
|
|
hmyAccounts: hmyAccounts, |
|
|
|
hmyAccounts: hmyAccounts, |
|
|
|
fnAccounts: fnAccounts, |
|
|
|
fnAccounts: fnAccounts, |
|
|
|
|
|
|
|
reshardingEpoch: reshardingEpoch, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -55,9 +60,10 @@ func MustNewInstance( |
|
|
|
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int, |
|
|
|
numShards uint32, numNodesPerShard, numHarmonyOperatedNodesPerShard int, |
|
|
|
hmyAccounts []genesis.DeployAccount, |
|
|
|
hmyAccounts []genesis.DeployAccount, |
|
|
|
fnAccounts []genesis.DeployAccount, |
|
|
|
fnAccounts []genesis.DeployAccount, |
|
|
|
|
|
|
|
reshardingEpoch []*big.Int, |
|
|
|
) Instance { |
|
|
|
) Instance { |
|
|
|
sc, err := NewInstance( |
|
|
|
sc, err := NewInstance( |
|
|
|
numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, hmyAccounts, fnAccounts) |
|
|
|
numShards, numNodesPerShard, numHarmonyOperatedNodesPerShard, hmyAccounts, fnAccounts, reshardingEpoch) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
panic(err) |
|
|
|
panic(err) |
|
|
|
} |
|
|
|
} |
|
|
@ -107,3 +113,8 @@ func (sc instance) FindAccount(blsPubKey string) (bool, *genesis.DeployAccount) |
|
|
|
} |
|
|
|
} |
|
|
|
return false, nil |
|
|
|
return false, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ReshardingEpoch returns the list of epoch number
|
|
|
|
|
|
|
|
func (sc instance) ReshardingEpoch() []*big.Int { |
|
|
|
|
|
|
|
return sc.reshardingEpoch |
|
|
|
|
|
|
|
} |
|
|
|