Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1494 from helium/adt/dont-take-early-snapshots
Browse files Browse the repository at this point in the history
Handle when the chain height is too low to take a snapshot
  • Loading branch information
Vagabond authored Dec 8, 2022
2 parents 01ccfb1 + 467c821 commit 4b704a5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ledger/v1/blockchain_ledger_snapshot_v1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@ snapshot(Ledger0, Blocks, Infos) ->
%% too far behind. Nodes that are reliably syncing will have a rocksdb checkpoint/snapshot at this
%% height which is safer to use.
{ok, Height} = blockchain_ledger_v1:current_height(Ledger0),
{ok, SnapLedger} = blockchain_ledger_v1:has_snapshot(Height - blockchain_txn:block_delay(), Ledger0),
snapshot(SnapLedger, Blocks, Infos, active).
case blockchain_ledger_v1:has_snapshot(Height - blockchain_txn:block_delay(), Ledger0) of
{ok, SnapLedger} ->
snapshot(SnapLedger, Blocks, Infos, active);
Error ->
Error
end.

-spec snapshot(
blockchain_ledger_v1:ledger(),
Expand Down

0 comments on commit 4b704a5

Please sign in to comment.