Add sharding schedule to node config

pull/1939/head
Eugene Kim 5 years ago
parent 22f0c4eac3
commit f91488b50b
  1. 3
      cmd/harmony/main.go
  2. 22
      internal/configs/node/config.go

@ -142,6 +142,9 @@ func initSetup() {
nodeconfig.GetDefaultConfig().Port = *port nodeconfig.GetDefaultConfig().Port = *port
nodeconfig.GetDefaultConfig().IP = *ip nodeconfig.GetDefaultConfig().IP = *ip
// Set sharding schedule
nodeconfig.SetShardingSchedule(shard.Schedule)
// Setup mem profiling. // Setup mem profiling.
memprofiling.GetMemProfiling().Config() memprofiling.GetMemProfiling().Config()

@ -11,6 +11,7 @@ import (
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
p2p_crypto "github.com/libp2p/go-libp2p-crypto" p2p_crypto "github.com/libp2p/go-libp2p-crypto"
shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding"
"github.com/harmony-one/harmony/internal/params" "github.com/harmony-one/harmony/internal/params"
) )
@ -89,6 +90,8 @@ type ConfigType struct {
DBDir string DBDir string
networkType NetworkType networkType NetworkType
shardingSchedule shardingconfig.Schedule
} }
// configs is a list of node configuration. // configs is a list of node configuration.
@ -249,6 +252,25 @@ func GetPublicRPC() bool {
return publicRPC return publicRPC
} }
// ShardingSchedule returns the sharding schedule for this node config.
func (conf *ConfigType) ShardingSchedule() shardingconfig.Schedule {
return conf.shardingSchedule
}
// SetShardingSchedule sets the sharding schedule for this node config.
func (conf *ConfigType) SetShardingSchedule(schedule shardingconfig.Schedule) {
conf.shardingSchedule = schedule
}
// SetShardingSchedule sets the sharding schedule for all config instances.
func SetShardingSchedule(schedule shardingconfig.Schedule) {
ensureShardConfigs()
defaultConfig.SetShardingSchedule(schedule)
for _, config := range shardConfigs {
config.SetShardingSchedule(schedule)
}
}
// ChainConfig returns the chain configuration for the network type. // ChainConfig returns the chain configuration for the network type.
func (t NetworkType) ChainConfig() params.ChainConfig { func (t NetworkType) ChainConfig() params.ChainConfig {
switch t { switch t {

Loading…
Cancel
Save