[RPC] Expose node metadata

pull/1611/head
Edgar Aroutiounian 5 years ago
parent 24a40baf18
commit c1b2d2ce0c
  1. 3
      internal/hmyapi/README.md
  2. 16
      internal/hmyapi/harmony.go

@ -10,6 +10,7 @@
* [x] hmy_protocolVersion - check protocol version
* [ ] net_version - get network id
* [ ] net_peerCount - peer count
* [x] hmy_getNodeMetadata - get node's version, bls key
### BlockChain info related
* [ ] hmy_gasPrice - return min-gas-price
@ -87,4 +88,4 @@ The ``shh`` is for the whisper protocol to communicate p2p and broadcast
* [ ] shh_newFilter
* [ ] shh_uninstallFilter
* [ ] shh_getFilterChanges
* [ ] shh_getMessages
* [ ] shh_getMessages

@ -6,6 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/harmony-one/harmony/api/proto"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
)
// PublicHarmonyAPI provides an API to access Harmony related information.
@ -41,3 +42,18 @@ func (s *PublicHarmonyAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) {
// TODO(ricl): add SuggestPrice API
return (*hexutil.Big)(big.NewInt(1)), nil
}
type NodeMetadata struct {
BLSPublicKey string `json:"blskey"`
Version string `json:"version"`
NetworkType string `json:"network"`
}
func (s *PublicHarmonyAPI) GetNodeMetadata() NodeMetadata {
cfg := nodeconfig.GetDefaultConfig()
return NodeMetadata{
cfg.ConsensusPubKey.SerializeToHexStr(),
nodeconfig.GetVersion(),
string(cfg.GetNetworkType()),
}
}

Loading…
Cancel
Save