diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index c9bc2e836..c9c4ec1ea 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -142,6 +142,9 @@ func initSetup() { nodeconfig.GetDefaultConfig().Port = *port nodeconfig.GetDefaultConfig().IP = *ip + // Set sharding schedule + nodeconfig.SetShardingSchedule(shard.Schedule) + // Setup mem profiling. memprofiling.GetMemProfiling().Config() diff --git a/internal/configs/node/config.go b/internal/configs/node/config.go index 695e592c9..45441c9ea 100644 --- a/internal/configs/node/config.go +++ b/internal/configs/node/config.go @@ -11,6 +11,7 @@ import ( "github.com/harmony-one/bls/ffi/go/bls" p2p_crypto "github.com/libp2p/go-libp2p-crypto" + shardingconfig "github.com/harmony-one/harmony/internal/configs/sharding" "github.com/harmony-one/harmony/internal/params" ) @@ -89,6 +90,8 @@ type ConfigType struct { DBDir string networkType NetworkType + + shardingSchedule shardingconfig.Schedule } // configs is a list of node configuration. @@ -249,6 +252,25 @@ func GetPublicRPC() bool { 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. func (t NetworkType) ChainConfig() params.ChainConfig { switch t {