From 79418c68bcd67d78807b8e717246138b7bf80e11 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Tue, 15 Oct 2019 07:27:05 +0000 Subject: [PATCH] [wallet] fix wallet with network type support Signed-off-by: Leo Chen --- .hmy/wallet.ini | 4 ++++ cmd/client/wallet/generated_wallet.ini.go | 4 ++++ cmd/client/wallet/main.go | 3 +++ cmd/client/wallet_stress_test/generated_wallet.ini.go | 4 ++++ internal/utils/configfile.go | 6 ++++++ 5 files changed, 21 insertions(+) diff --git a/.hmy/wallet.ini b/.hmy/wallet.ini index 43242d355..dccdbdc3a 100644 --- a/.hmy/wallet.ini +++ b/.hmy/wallet.ini @@ -5,6 +5,7 @@ bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHN bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj shards = 4 +network = mainnet [main.shard0.rpc] rpc = l0.t.hmny.io:14555 @@ -26,6 +27,7 @@ rpc = s3.t.hmny.io:14555 chain_id = 2 bootnode = /ip4/127.0.0.1/tcp/19876/p2p/Qmc1V6W7BwX8Ugb42Ti8RnXF1rY5PF7nnZ6bKBryCgi6cv shards = 2 +network = localnet [local.shard0.rpc] rpc = 127.0.0.1:14555 @@ -43,6 +45,7 @@ bootnode = /ip4/54.213.43.194/tcp/9868/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHN bootnode = /ip4/100.26.90.187/tcp/9868/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv bootnode = /ip4/13.113.101.219/tcp/12018/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX shards = 2 +network = testnet [beta.shard0.rpc] rpc = l0.b.hmny.io:14555 @@ -57,6 +60,7 @@ chain_id = 3 bootnode = /ip4/54.86.126.90/tcp/9889/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv bootnode = /ip4/52.40.84.2/tcp/9889/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9 shards = 4 +network = pangaea [pangaea.shard0.rpc] rpc = l0.p.hmny.io:14555 diff --git a/cmd/client/wallet/generated_wallet.ini.go b/cmd/client/wallet/generated_wallet.ini.go index f7a4206bb..170882e5f 100644 --- a/cmd/client/wallet/generated_wallet.ini.go +++ b/cmd/client/wallet/generated_wallet.ini.go @@ -8,6 +8,7 @@ bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHN bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj shards = 4 +network = mainnet [main.shard0.rpc] rpc = l0.t.hmny.io:14555 @@ -29,6 +30,7 @@ rpc = s3.t.hmny.io:14555 chain_id = 2 bootnode = /ip4/127.0.0.1/tcp/19876/p2p/Qmc1V6W7BwX8Ugb42Ti8RnXF1rY5PF7nnZ6bKBryCgi6cv shards = 2 +network = localnet [local.shard0.rpc] rpc = 127.0.0.1:14555 @@ -46,6 +48,7 @@ bootnode = /ip4/54.213.43.194/tcp/9868/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHN bootnode = /ip4/100.26.90.187/tcp/9868/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv bootnode = /ip4/13.113.101.219/tcp/12018/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX shards = 2 +network = testnet [beta.shard0.rpc] rpc = l0.b.hmny.io:14555 @@ -60,6 +63,7 @@ chain_id = 3 bootnode = /ip4/54.86.126.90/tcp/9889/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv bootnode = /ip4/52.40.84.2/tcp/9889/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9 shards = 4 +network = pangaea [pangaea.shard0.rpc] rpc = l0.p.hmny.io:14555 diff --git a/cmd/client/wallet/main.go b/cmd/client/wallet/main.go index f375bdf85..abdd7f28b 100644 --- a/cmd/client/wallet/main.go +++ b/cmd/client/wallet/main.go @@ -123,6 +123,7 @@ var ( ) var ( + networkType string walletProfile *utils.WalletProfile ks *keystore.KeyStore ) @@ -307,6 +308,8 @@ func createWalletNode() *node.Node { w.Client = client.NewClient(w.GetHost(), uint32(shardID)) w.NodeConfig.SetRole(nodeconfig.ClientNode) + netType := nodeconfig.NetworkType(walletProfile.Network) + nodeconfig.SetNetworkType(netType) w.ServiceManagerSetup() w.RunServices() return w diff --git a/cmd/client/wallet_stress_test/generated_wallet.ini.go b/cmd/client/wallet_stress_test/generated_wallet.ini.go index f7a4206bb..170882e5f 100644 --- a/cmd/client/wallet_stress_test/generated_wallet.ini.go +++ b/cmd/client/wallet_stress_test/generated_wallet.ini.go @@ -8,6 +8,7 @@ bootnode = /ip4/54.213.43.194/tcp/9874/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHN bootnode = /ip4/13.113.101.219/tcp/12019/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX bootnode = /ip4/99.81.170.167/tcp/12019/p2p/QmRVbTpEYup8dSaURZfF6ByrMTSKa4UyUzJhSjahFzRqNj shards = 4 +network = mainnet [main.shard0.rpc] rpc = l0.t.hmny.io:14555 @@ -29,6 +30,7 @@ rpc = s3.t.hmny.io:14555 chain_id = 2 bootnode = /ip4/127.0.0.1/tcp/19876/p2p/Qmc1V6W7BwX8Ugb42Ti8RnXF1rY5PF7nnZ6bKBryCgi6cv shards = 2 +network = localnet [local.shard0.rpc] rpc = 127.0.0.1:14555 @@ -46,6 +48,7 @@ bootnode = /ip4/54.213.43.194/tcp/9868/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHN bootnode = /ip4/100.26.90.187/tcp/9868/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv bootnode = /ip4/13.113.101.219/tcp/12018/p2p/QmQayinFSgMMw5cSpDUiD9pQ2WeP6WNmGxpZ6ou3mdVFJX shards = 2 +network = testnet [beta.shard0.rpc] rpc = l0.b.hmny.io:14555 @@ -60,6 +63,7 @@ chain_id = 3 bootnode = /ip4/54.86.126.90/tcp/9889/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3tnEv bootnode = /ip4/52.40.84.2/tcp/9889/p2p/QmZJJx6AdaoEkGLrYG4JeLCKeCKDjnFz2wfHNHxAqFSGA9 shards = 4 +network = pangaea [pangaea.shard0.rpc] rpc = l0.p.hmny.io:14555 diff --git a/internal/utils/configfile.go b/internal/utils/configfile.go index 5eed8b37d..aa2123d1a 100644 --- a/internal/utils/configfile.go +++ b/internal/utils/configfile.go @@ -19,6 +19,7 @@ type WalletProfile struct { Bootnodes []string Shards int RPCServer [][]p2p.Peer + Network string } // ReadWalletProfile reads an ini file and return WalletProfile @@ -42,6 +43,11 @@ func ReadWalletProfile(iniBytes []byte, profile string) (*WalletProfile, error) } else { return nil, fmt.Errorf("can't find bootnode key") } + if sec.HasKey("network") { + config.Network = sec.Key("network").String() + } else { + config.Network = "devnet" + } if sec.HasKey("chain_id") { config.ChainID = sec.Key("chain_id").String() } else {