les: fix serverHandler crash after setHead (#24200)

release/1.10
Martin Holst Swende 3 years ago committed by GitHub
parent 3ccd6b6dbb
commit 335914a63a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      les/server_handler.go

@ -421,7 +421,10 @@ func (h *serverHandler) broadcastLoop() {
} }
var reorg uint64 var reorg uint64
if lastHead != nil { if lastHead != nil {
reorg = lastHead.Number.Uint64() - rawdb.FindCommonAncestor(h.chainDb, header, lastHead).Number.Uint64() // If a setHead has been performed, the common ancestor can be nil.
if ancestor := rawdb.FindCommonAncestor(h.chainDb, header, lastHead); ancestor != nil {
reorg = lastHead.Number.Uint64() - ancestor.Number.Uint64()
}
} }
lastHead, lastTd = header, td lastHead, lastTd = header, td
log.Debug("Announcing block to peers", "number", number, "hash", hash, "td", td, "reorg", reorg) log.Debug("Announcing block to peers", "number", number, "hash", hash, "td", td, "reorg", reorg)

Loading…
Cancel
Save