correct peer on stats

This commit is contained in:
Tuna 2019-01-30 22:41:44 +07:00
parent cedec9f6f9
commit 2f5c613341
2 changed files with 6 additions and 2 deletions

View file

@ -387,7 +387,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
header := currentHeader header := currentHeader
// Sometimes, the latest block hasn't been inserted to chain yet // Sometimes, the latest block hasn't been inserted to chain yet
// getSnapshot from parent block if it exists // getSnapshot from parent block if it exists
parentHeader := eth.blockchain.GetHeader(currentHeader.ParentHash, currentHeader.Number.Uint64() - 1) parentHeader := eth.blockchain.GetHeader(currentHeader.ParentHash, currentHeader.Number.Uint64()-1)
if parentHeader != nil { if parentHeader != nil {
// not genesis block // not genesis block
header = parentHeader header = parentHeader
@ -723,3 +723,7 @@ func rewardInflation(chainReward *big.Int, number uint64, blockPerYear uint64) *
return chainReward return chainReward
} }
func (s *Ethereum) GetPeer() int {
return len(s.protocolManager.peers.peers)
}

View file

@ -704,7 +704,7 @@ func (s *Service) reportStats(conn *websocket.Conn) error {
Active: true, Active: true,
Mining: mining, Mining: mining,
Hashrate: hashrate, Hashrate: hashrate,
Peers: s.server.PeerCount(), Peers: s.eth.GetPeer(),
GasPrice: gasprice, GasPrice: gasprice,
Syncing: syncing, Syncing: syncing,
Uptime: 100, Uptime: 100,