[RPC] Expose node metadata

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

@ -10,6 +10,7 @@
* [x] hmy_protocolVersion - check protocol version * [x] hmy_protocolVersion - check protocol version
* [ ] net_version - get network id * [ ] net_version - get network id
* [ ] net_peerCount - peer count * [ ] net_peerCount - peer count
* [x] hmy_getNodeMetadata - get node's version, bls key
### BlockChain info related ### BlockChain info related
* [ ] hmy_gasPrice - return min-gas-price * [ ] hmy_gasPrice - return min-gas-price

@ -6,6 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/harmony-one/harmony/api/proto" "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. // 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 // TODO(ricl): add SuggestPrice API
return (*hexutil.Big)(big.NewInt(1)), nil 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