From b41b8c823a1cbbaf009dcef6969928ac36eb6503 Mon Sep 17 00:00:00 2001 From: Terence Tsao Date: Tue, 12 Jun 2018 20:11:07 -0700 Subject: [PATCH] sharding: use pointer for default config Former-commit-id: 47354dddbeb7c5db47c79c5b929524d221f35814 [formerly 570a02de295c3d30c1b03327615dcb3d47c8c363] Former-commit-id: 329af4b67168e0a58b7bae38c16cae4354fbf808 --- cmd/utils/flags.go | 4 ++-- sharding/node/backend.go | 6 +++--- sharding/notary/service_test.go | 6 +++--- sharding/params/config.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 4724b6178..10df3530f 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -55,7 +55,7 @@ import ( "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/p2p/netutil" "github.com/ethereum/go-ethereum/params" - sparams "github.com/ethereum/go-ethereum/sharding/params" + shardparams "github.com/ethereum/go-ethereum/sharding/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "gopkg.in/urfave/cli.v1" ) @@ -536,7 +536,7 @@ var ( // Sharding Settings DepositFlag = cli.BoolFlag{ Name: "deposit", - Usage: "To become a notary in a sharding node, " + new(big.Int).Div(sparams.DefaultShardConfig.NotaryDeposit, new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)).String() + " ETH will be deposited into SMC", + Usage: "To become a notary in a sharding node, " + new(big.Int).Div(shardparams.DefaultShardConfig.NotaryDeposit, new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)).String() + " ETH will be deposited into SMC", } ActorFlag = cli.StringFlag{ Name: "actor", diff --git a/sharding/node/backend.go b/sharding/node/backend.go index 7cd0fc0f3..7ebd7dccf 100644 --- a/sharding/node/backend.go +++ b/sharding/node/backend.go @@ -38,7 +38,7 @@ const shardChainDbName = "shardchaindata" // it contains APIs and fields that handle the different components of the sharded // Ethereum network. type ShardEthereum struct { - shardConfig *params.ShardConfig // Holds necessary information to configure shards. + shardConfig *params.ShardConfig // Holds necessary information to configure shard node. txPool *txpool.ShardTXPool // Defines the sharding-specific txpool. To be designed. actor sharding.Actor // Either notary, proposer, or observer. shardChainDb ethdb.Database // Access to the persistent db to store shard data. @@ -89,8 +89,8 @@ func New(ctx *cli.Context) (*ShardEthereum, error) { // Adds the initialized SMCClient to the ShardEthereum instance. shardEthereum.smcClient = smcClient - // Configure shardConfig by loading from default. - shardEthereum.shardConfig = ¶ms.DefaultShardConfig + // Configure shardConfig by loading the default. + shardEthereum.shardConfig = params.DefaultShardConfig // Adds the initialized shardChainDb to the ShardEthereum instance. shardEthereum.shardChainDb = shardChainDb diff --git a/sharding/notary/service_test.go b/sharding/notary/service_test.go index aee5eeca5..da48c7aa3 100644 --- a/sharding/notary/service_test.go +++ b/sharding/notary/service_test.go @@ -154,13 +154,13 @@ func TestJoinNotaryPool(t *testing.T) { } client.SetDepositFlag(false) - err = joinNotaryPool(¶ms.DefaultShardConfig, client) + err = joinNotaryPool(params.DefaultShardConfig, client) if err == nil { t.Error("Joined notary pool while --deposit was not present") } client.SetDepositFlag(true) - err = joinNotaryPool(¶ms.DefaultShardConfig, client) + err = joinNotaryPool(params.DefaultShardConfig, client) if err != nil { t.Fatal(err) } @@ -176,7 +176,7 @@ func TestJoinNotaryPool(t *testing.T) { } // Trying to join while deposited should do nothing - err = joinNotaryPool(¶ms.DefaultShardConfig, client) + err = joinNotaryPool(params.DefaultShardConfig, client) if err != nil { t.Error(err) } diff --git a/sharding/params/config.go b/sharding/params/config.go index 38752a1f3..748f93d44 100644 --- a/sharding/params/config.go +++ b/sharding/params/config.go @@ -10,7 +10,7 @@ import ( ) // DefaultShardConfig contains default configs for node to use in the sharded universe -var DefaultShardConfig = ShardConfig{ +var DefaultShardConfig = &ShardConfig{ SMCAddress: common.HexToAddress("0x0"), PeriodLength: 5, NotaryDeposit: new(big.Int).Exp(big.NewInt(10), big.NewInt(21), nil), // 1000 ETH @@ -22,7 +22,7 @@ var DefaultShardConfig = ShardConfig{ } // DefaultShardChainConfig contains default chain configs of an individual shard. -var DefaultShardChainConfig = ShardChainConfig{} +var DefaultShardChainConfig = &ShardChainConfig{} // ShardConfig contains configs for node to participate in the sharded universe. type ShardConfig struct {