[rpc] added current block number in utility metadata

pull/3667/head
Jacky Wang 4 years ago
parent 343dbe89b3
commit 6705e233ee
No known key found for this signature in database
GPG Key ID: 1085CE5F4FF5842C
  1. 33
      hmy/hmy.go
  2. 33
      rpc/common/types.go

@ -191,22 +191,23 @@ func (hmy *Harmony) GetNodeMetadata() commonRPC.NodeMetadata {
consensusInternal := hmy.NodeAPI.GetConsensusInternal() consensusInternal := hmy.NodeAPI.GetConsensusInternal()
return commonRPC.NodeMetadata{ return commonRPC.NodeMetadata{
BLSPublicKey: blsKeys, BLSPublicKey: blsKeys,
Version: nodeconfig.GetVersion(), Version: nodeconfig.GetVersion(),
NetworkType: string(cfg.GetNetworkType()), NetworkType: string(cfg.GetNetworkType()),
ChainConfig: *hmy.ChainConfig(), ChainConfig: *hmy.ChainConfig(),
IsLeader: hmy.IsLeader(), IsLeader: hmy.IsLeader(),
ShardID: hmy.ShardID, ShardID: hmy.ShardID,
CurrentEpoch: header.Epoch().Uint64(), CurrentBlockNum: header.Number().Uint64(),
BlocksPerEpoch: blockEpoch, CurrentEpoch: header.Epoch().Uint64(),
Role: cfg.Role().String(), BlocksPerEpoch: blockEpoch,
DNSZone: cfg.DNSZone, Role: cfg.Role().String(),
Archival: cfg.GetArchival(), DNSZone: cfg.DNSZone,
NodeBootTime: hmy.NodeAPI.GetNodeBootTime(), Archival: cfg.GetArchival(),
PeerID: nodeconfig.GetPeerID(), NodeBootTime: hmy.NodeAPI.GetNodeBootTime(),
Consensus: consensusInternal, PeerID: nodeconfig.GetPeerID(),
C: c, Consensus: consensusInternal,
SyncPeers: syncPeers, C: c,
SyncPeers: syncPeers,
} }
} }

@ -49,22 +49,23 @@ type ConsensusInternal struct {
// NodeMetadata captures select metadata of the RPC answering node // NodeMetadata captures select metadata of the RPC answering node
type NodeMetadata struct { type NodeMetadata struct {
BLSPublicKey []string `json:"blskey"` BLSPublicKey []string `json:"blskey"`
Version string `json:"version"` Version string `json:"version"`
NetworkType string `json:"network"` NetworkType string `json:"network"`
ChainConfig params.ChainConfig `json:"chain-config"` ChainConfig params.ChainConfig `json:"chain-config"`
IsLeader bool `json:"is-leader"` IsLeader bool `json:"is-leader"`
ShardID uint32 `json:"shard-id"` ShardID uint32 `json:"shard-id"`
CurrentEpoch uint64 `json:"current-epoch"` CurrentBlockNum uint64 `json:"current-number"`
BlocksPerEpoch *uint64 `json:"blocks-per-epoch,omitempty"` CurrentEpoch uint64 `json:"current-epoch"`
Role string `json:"role"` BlocksPerEpoch *uint64 `json:"blocks-per-epoch,omitempty"`
DNSZone string `json:"dns-zone"` Role string `json:"role"`
Archival bool `json:"is-archival"` DNSZone string `json:"dns-zone"`
NodeBootTime int64 `json:"node-unix-start-time"` Archival bool `json:"is-archival"`
PeerID peer.ID `json:"peerid"` NodeBootTime int64 `json:"node-unix-start-time"`
Consensus ConsensusInternal `json:"consensus"` PeerID peer.ID `json:"peerid"`
C C `json:"p2p-connectivity"` Consensus ConsensusInternal `json:"consensus"`
SyncPeers map[string]int `json:"sync-peers",omitempty` C C `json:"p2p-connectivity"`
SyncPeers map[string]int `json:"sync-peers",omitempty`
} }
// P captures the connected peers per topic // P captures the connected peers per topic

Loading…
Cancel
Save