From f91488b50bce0559739011a02526e3306634364b Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Mon, 2 Dec 2019 15:43:29 -0800 Subject: [PATCH] Add sharding schedule to node config --- cmd/harmony/main.go | 3 +++ internal/configs/node/config.go | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) 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 {