From d5584389663fe391e1a9608f1d3d88fa0f52f96f Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Sat, 22 Jun 2019 12:50:32 -0700 Subject: [PATCH] disable rpc for mainnet --- cmd/harmony/main.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 626bb0edb..70ebaae90 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -139,6 +139,12 @@ var ( "Do not propose view change (testing only)") ) +const ( + MainNet = "mainnet" + TestNet = "testnet" + DevNet = "devnet" +) + func initSetup() { // Set port and ip to global config. nodeconfig.GetDefaultConfig().Port = *port @@ -254,11 +260,11 @@ func createGlobalConfig() *nodeconfig.ConfigType { // Set network type switch *networkType { - case "mainnet": + case MainNet: nodeConfig.SetNetworkType(nodeconfig.Mainnet) - case "testnet": + case TestNet: nodeConfig.SetNetworkType(nodeconfig.Testnet) - case "devnet": + case DevNet: nodeConfig.SetNetworkType(nodeconfig.Devnet) default: panic(fmt.Sprintf("invalid network type: %s", *networkType)) @@ -487,8 +493,12 @@ func main() { } go currentNode.SupportSyncing() currentNode.ServiceManagerSetup() - if err := currentNode.StartRPC(*port); err != nil { - ctxerror.Warn(utils.GetLogger(), err, "StartRPC failed") + + // RPC for SDK not supported for mainnet. + if *networkType != MainNet { + if err := currentNode.StartRPC(*port); err != nil { + ctxerror.Warn(utils.GetLogger(), err, "StartRPC failed") + } } currentNode.RunServices() currentNode.StartServer()