les: separate peer into clientPeer and serverPeer (#19991)
* les: separate peer into clientPeer and serverPeer * les: address comments
This commit is contained in:
@ -51,7 +51,7 @@ const (
|
||||
// In addition to the checkpoint registered in the registrar contract, there are
|
||||
// several legacy hardcoded checkpoints in our codebase. These checkpoints are
|
||||
// also considered as valid.
|
||||
func (h *clientHandler) validateCheckpoint(peer *peer) error {
|
||||
func (h *clientHandler) validateCheckpoint(peer *serverPeer) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||
defer cancel()
|
||||
|
||||
@ -87,7 +87,7 @@ func (h *clientHandler) validateCheckpoint(peer *peer) error {
|
||||
}
|
||||
|
||||
// synchronise tries to sync up our local chain with a remote peer.
|
||||
func (h *clientHandler) synchronise(peer *peer) {
|
||||
func (h *clientHandler) synchronise(peer *serverPeer) {
|
||||
// Short circuit if the peer is nil.
|
||||
if peer == nil {
|
||||
return
|
||||
@ -95,7 +95,7 @@ func (h *clientHandler) synchronise(peer *peer) {
|
||||
// Make sure the peer's TD is higher than our own.
|
||||
latest := h.backend.blockchain.CurrentHeader()
|
||||
currentTd := rawdb.ReadTd(h.backend.chainDb, latest.Hash(), latest.Number.Uint64())
|
||||
if currentTd != nil && peer.headBlockInfo().Td.Cmp(currentTd) < 0 {
|
||||
if currentTd != nil && peer.Td().Cmp(currentTd) < 0 {
|
||||
return
|
||||
}
|
||||
// Recap the checkpoint.
|
||||
|
Reference in New Issue
Block a user