les: historical data garbage collection (#19570)
This change introduces garbage collection for the light client. Historical chain data is deleted periodically. If you want to disable the GC, use the --light.nopruning flag.
This commit is contained in:
@ -110,14 +110,16 @@ func (r *BlockRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||
body := bodies[0]
|
||||
|
||||
// Retrieve our stored header and validate block content against it
|
||||
header := rawdb.ReadHeader(db, r.Hash, r.Number)
|
||||
if header == nil {
|
||||
if r.Header == nil {
|
||||
r.Header = rawdb.ReadHeader(db, r.Hash, r.Number)
|
||||
}
|
||||
if r.Header == nil {
|
||||
return errHeaderUnavailable
|
||||
}
|
||||
if header.TxHash != types.DeriveSha(types.Transactions(body.Transactions)) {
|
||||
if r.Header.TxHash != types.DeriveSha(types.Transactions(body.Transactions)) {
|
||||
return errTxHashMismatch
|
||||
}
|
||||
if header.UncleHash != types.CalcUncleHash(body.Uncles) {
|
||||
if r.Header.UncleHash != types.CalcUncleHash(body.Uncles) {
|
||||
return errUncleHashMismatch
|
||||
}
|
||||
// Validations passed, encode and store RLP
|
||||
|
Reference in New Issue
Block a user