[debug] add debug rpc calls

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3347/head
Leo Chen 4 years ago
parent 4089ea0695
commit c2e962a035
  1. 21
      consensus/debug.go
  2. 7
      hmy/hmy.go
  3. 20
      node/api.go
  4. 26
      rpc/debug.go

@ -0,0 +1,21 @@
package consensus
// GetConsensusPhase ..
func (c *Consensus) GetConsensusPhase() string {
return c.phase.String()
}
// GetConsensusMode ..
func (c *Consensus) GetConsensusMode() string {
return c.current.mode.String()
}
// GetConsensusCurViewID ..
func (c *Consensus) GetConsensusCurViewID() uint64 {
return c.current.GetViewID()
}
// GetConsensusViewID ..
func (c *Consensus) GetConsensusViewID() uint64 {
return c.viewID
}

@ -92,6 +92,13 @@ type NodeAPI interface {
ListPeer(topic string) []peer.ID
ListTopic() []string
ListBlockedPeer() []peer.ID
// debug API
GetConsensusMode() string
GetConsensusPhase() string
GetConsensusViewID() uint64
GetConsensusCurViewID() uint64
ShutDown()
}
// New creates a new Harmony object (including the

@ -106,3 +106,23 @@ func (node *Node) APIs(harmony *hmy.Harmony) []rpc.API {
},
}
}
// GetConsensusMode returns the current consensus mode
func (node *Node) GetConsensusMode() string {
return node.Consensus.GetConsensusMode()
}
// GetConsensusPhase returns the current consensus phase
func (node *Node) GetConsensusPhase() string {
return node.Consensus.GetConsensusPhase()
}
// GetConsensusViewID returns the consensus.viewID
func (node *Node) GetConsensusViewID() uint64 {
return node.Consensus.GetConsensusViewID()
}
// GetConsensusCurViewID returns the consensus.current.viewID
func (node *Node) GetConsensusCurViewID() uint64 {
return node.Consensus.GetConsensusCurViewID()
}

@ -38,3 +38,29 @@ func (*PrivateDebugService) SetLogVerbosity(ctx context.Context, level int) (map
utils.SetLogVerbosity(verbosity)
return map[string]interface{}{"verbosity": verbosity.String()}, nil
}
func (s *PrivateDebugService) ConsensusViewID(
ctx context.Context,
) uint64 {
return s.hmy.NodeAPI.GetConsensusViewID()
}
func (s *PrivateDebugService) ConsensusCurViewID(
ctx context.Context,
) uint64 {
return s.hmy.NodeAPI.GetConsensusCurViewID()
}
// GetConsensusMode return the current consensus mode
func (s *PrivateDebugService) GetConsensusMode(
ctx context.Context,
) string {
return s.hmy.NodeAPI.GetConsensusMode()
}
// GetConsensusPhase return the current consensus mode
func (s *PrivateDebugService) GetConsensusPhase(
ctx context.Context,
) string {
return s.hmy.NodeAPI.GetConsensusPhase()
}

Loading…
Cancel
Save