bor/consensus: Only write Snapshots to DB for checkpoints (#5369)

This commit is contained in:
Nicolas Gotchac 2022-09-17 08:25:47 -04:00 committed by GitHub
parent 0e8d5d41fc
commit a18c088771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -554,11 +554,14 @@ func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash co
return nil, err
}
c.recents.Add(snap.Hash, snap)
// We've generated a new checkpoint snapshot, save to disk
if err = snap.store(c.DB); err != nil {
return nil, err
if snap.Number%checkpointInterval == 0 {
// We've generated a new checkpoint snapshot, save to disk
if err = snap.store(c.DB); err != nil {
return nil, err
}
log.Trace("Stored snapshot to disk", "number", snap.Number, "hash", snap.Hash)
}
log.Trace("Stored snapshot to disk", "number", snap.Number, "hash", snap.Hash)
}
if cont {
snap = nil