[rpc] add hmyv2_getConfig rpc

pull/3734/head
Peter Chung 4 years ago
parent de603b3b94
commit 9fe7a51efa
  1. 20
      cmd/harmony/main.go
  2. 1
      hmy/hmy.go
  3. 8
      node/api.go
  4. 2
      node/node.go
  5. 1
      rpc/common/types.go
  6. 8
      rpc/debug.go

@ -1,7 +1,6 @@
package main
import (
"encoding/json"
"fmt"
harmonyconfig "github.com/harmony-one/harmony/internal/configs/harmony"
rpc_common "github.com/harmony-one/harmony/rpc/common"
@ -297,17 +296,6 @@ func setupNodeAndRun(hc harmonyconfig.HarmonyConfig) {
os.Exit(1)
}
if hc.Log.VerbosePrints["config"] {
if cfgJson, err := json.MarshalIndent(rpc_common.Config{
HarmonyConfig: hc,
NodeConfig: *nodeConfig,
}, "", " "); err != nil {
panic(err)
} else {
println(string(cfgJson))
}
}
// Update ethereum compatible chain ids
params.UpdateEthChainIDByShard(nodeConfig.ShardID)
@ -393,6 +381,14 @@ func setupNodeAndRun(hc harmonyconfig.HarmonyConfig) {
nodeconfig.SetPeerID(myHost.GetID())
if hc.Log.VerbosePrints["config"] {
utils.Logger().Info().Interface("config", rpc_common.Config{
HarmonyConfig: hc,
NodeConfig: *nodeConfig,
ChainConfig: *currentNode.Blockchain().Config(),
}).Msg("verbose prints config")
}
// Setup services
if hc.Sync.Enabled {
setupSyncService(currentNode, myHost, hc)

@ -106,6 +106,7 @@ type NodeAPI interface {
GetConsensusPhase() string
GetConsensusViewChangingID() uint64
GetConsensusCurViewID() uint64
GetConfig() commonRPC.Config
ShutDown()
}

@ -142,3 +142,11 @@ func (node *Node) GetConsensusInternal() rpc_common.ConsensusInternal {
ConsensusTime: node.Consensus.GetFinality(),
}
}
func (node *Node) GetConfig() rpc_common.Config {
return rpc_common.Config{
HarmonyConfig: node.HarmonyConfig,
NodeConfig: *node.NodeConfig,
ChainConfig: node.chainConfig,
}
}

@ -3,6 +3,7 @@ package node
import (
"context"
"fmt"
"github.com/harmony-one/harmony/internal/configs/harmony"
"math/big"
"os"
"strings"
@ -105,6 +106,7 @@ type Node struct {
ContractAddresses []common.Address
// Channel to notify consensus service to really start consensus
startConsensus chan struct{}
HarmonyConfig harmony.HarmonyConfig
// node configuration, including group ID, shard ID, etc
NodeConfig *nodeconfig.ConfigType
// Chain configuration.

@ -86,4 +86,5 @@ type NodePeerInfo struct {
type Config struct {
HarmonyConfig harmonyconfig.HarmonyConfig
NodeConfig nodeconfig.ConfigType
ChainConfig params.ChainConfig
}

@ -2,6 +2,7 @@ package rpc
import (
"context"
commonRPC "github.com/harmony-one/harmony/rpc/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
@ -64,3 +65,10 @@ func (s *PrivateDebugService) GetConsensusPhase(
) string {
return s.hmy.NodeAPI.GetConsensusPhase()
}
// GetConfig get harmony config
func (s *PrivateDebugService) GetConfig(
ctx context.Context,
) commonRPC.Config {
return s.hmy.NodeAPI.GetConfig()
}

Loading…
Cancel
Save