From a18c08877171f7fc2788ff465ff6f178b73716e8 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Sat, 17 Sep 2022 08:25:47 -0400 Subject: [PATCH] bor/consensus: Only write Snapshots to DB for checkpoints (#5369) --- consensus/bor/bor.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/consensus/bor/bor.go b/consensus/bor/bor.go index 6fb69f3f1..229dc18e0 100644 --- a/consensus/bor/bor.go +++ b/consensus/bor/bor.go @@ -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