77{-# LANGUAGE ScopedTypeVariables #-}
88{-# LANGUAGE StandaloneDeriving #-}
99{-# LANGUAGE StandaloneKindSignatures #-}
10+ {-# LANGUAGE TupleSections #-}
1011{-# LANGUAGE TypeApplications #-}
1112{-# LANGUAGE TypeFamilies #-}
1213{-# LANGUAGE TypeOperators #-}
@@ -26,6 +27,7 @@ import qualified Data.Foldable as Foldable
2627import Data.Functor.Contravariant ((>$<) )
2728import Data.Kind (Type )
2829import Data.List.NonEmpty (NonEmpty )
30+ import qualified Data.List.NonEmpty as NonEmpty
2931import Data.Maybe (mapMaybe )
3032import Data.Set (Set )
3133import qualified Data.Set as Set
@@ -364,7 +366,7 @@ implTryTakeSnapshot snapManager env copyBlocks snapshotRequestTime getRandomDela
364366 -- Prune the 'LedgerSeq' such that the resulting anchor state has slot
365367 -- number @slot@.
366368 let pruneStrat = LedgerDbPruneBeforeSlot (slot + 1 )
367- duplicateStateRef $ anchorHandle $ snd $ prune pruneStrat lseq
369+ (slot,) <$> ( duplicateStateRef $ anchorHandle $ snd $ prune pruneStrat lseq)
368370
369371 -- look at the list of the ledger tables handles from the previous step and take the snapshots
370372 case handles of
@@ -373,11 +375,15 @@ implTryTakeSnapshot snapManager env copyBlocks snapshotRequestTime getRandomDela
373375 copyBlocks
374376
375377 delayBeforeSnapshotting <- getRandomDelay (onDiskSnapshotDelayRange (ldbSnapshotPolicy env))
378+ let slotsOfHandles =
379+ case NonEmpty. nonEmpty $ map fst handles of
380+ Nothing -> error " impossible: empty handles, see pattern-match above"
381+ Just slots -> slots
376382 traceWith (LedgerDBSnapshotEvent >$< ldbTracer env) $
377- SnapshotRequestDelayed snapshotRequestTime delayBeforeSnapshotting ( length handles)
383+ SnapshotRequestDelayed snapshotRequestTime delayBeforeSnapshotting slotsOfHandles
378384 threadDelay delayBeforeSnapshotting
379385
380- for_ handles $ \ h -> do
386+ for_ handles $ \ (_, h) -> do
381387 Monad. void $ takeSnapshot snapManager Nothing h
382388
383389 atomically $ writeTVar (ldbLastSnapshotRequestedAt env) (Just $! snapshotRequestTime)
0 commit comments