rpc: add max peer block height into /status rpc call (#6610)

use  `maxPeerBlockHeight` information to show the current network's best height.

Closes #3983
Relate to #3365

ref: the`highestBlock` in the response of `eth.isSyncing` call
https://web3js.readthedocs.io/en/v1.3.4/web3-eth.html#issyncing
This commit is contained in:
JayT106
2021-06-24 15:11:10 +00:00
committed by GitHub
parent ae5f98881b
commit 2cc872543b
10 changed files with 38 additions and 14 deletions
+4
View File
@@ -589,3 +589,7 @@ FOR_LOOP:
}
}
}
func (r *Reactor) GetMaxPeerBlockHeight() int64 {
return r.pool.MaxPeerHeight()
}
+6
View File
@@ -590,3 +590,9 @@ func (r *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor {
},
}
}
func (r *BlockchainReactor) GetMaxPeerBlockHeight() int64 {
r.mtx.RLock()
defer r.mtx.RUnlock()
return r.maxPeerHeight
}
+8
View File
@@ -98,6 +98,14 @@ const (
type ReactorOption func(*Reactor)
// Temporary interface for switching to fast sync, we should get rid of v0.
// See: https://github.com/tendermint/tendermint/issues/4595
type FastSyncReactor interface {
SwitchToFastSync(sm.State) error
GetMaxPeerBlockHeight() int64
}
// Reactor defines a reactor for the consensus service.
type Reactor struct {
service.BaseService