diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-06-03 22:03:33 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-06-04 21:13:42 +0200 |
| commit | 9fd045d5dd5a2d9b210847451fb6fc0837a00068 (patch) | |
| tree | dce40a1726a3a2dd26589780553cabde59703b24 /src/Erebos/Storage | |
| parent | 2f403246cb0eb4a0c39598f03cb2116ad00fc500 (diff) | |
Diffstat (limited to 'src/Erebos/Storage')
| -rw-r--r-- | src/Erebos/Storage/Graph.hs | 2 | ||||
| -rw-r--r-- | src/Erebos/Storage/Head.hs | 2 | ||||
| -rw-r--r-- | src/Erebos/Storage/Internal.hs | 39 |
3 files changed, 7 insertions, 36 deletions
diff --git a/src/Erebos/Storage/Graph.hs b/src/Erebos/Storage/Graph.hs index 1312941..67daa3b 100644 --- a/src/Erebos/Storage/Graph.hs +++ b/src/Erebos/Storage/Graph.hs @@ -39,7 +39,7 @@ import Data.Set qualified as S import System.IO.Unsafe (unsafePerformIO) -import Erebos.Object +import Erebos.Object.Internal import Erebos.Storable.Internal import Erebos.Storage.Internal import Erebos.Util diff --git a/src/Erebos/Storage/Head.hs b/src/Erebos/Storage/Head.hs index 87212f0..f6ddcfa 100644 --- a/src/Erebos/Storage/Head.hs +++ b/src/Erebos/Storage/Head.hs @@ -29,7 +29,7 @@ import Control.Monad.Reader import Data.Bifunctor import Data.Typeable -import Erebos.Object +import Erebos.Object.Internal import Erebos.Storable.Internal import Erebos.Storage.Backend import Erebos.Storage.Internal diff --git a/src/Erebos/Storage/Internal.hs b/src/Erebos/Storage/Internal.hs index c7255ef..e6fafe4 100644 --- a/src/Erebos/Storage/Internal.hs +++ b/src/Erebos/Storage/Internal.hs @@ -1,13 +1,11 @@ module Erebos.Storage.Internal ( Storage'(..), Storage, PartialStorage, - Ref'(..), Ref, PartialRef, RefDigest(..), WatchID, startWatchID, nextWatchID, WatchList(..), WatchListItem(..), watchListAdd, watchListDel, - refStorage, - refDigest, refDigestFromByteString, - showRef, showRefDigest, showRefDigestParts, + refDigestFromByteString, + showRefDigest, showRefDigestParts, readRefDigest, hashToRefDigest, @@ -176,36 +174,9 @@ newtype RefDigest = RefDigest (Digest Blake2b_256) instance Show RefDigest where show = BC.unpack . showRefDigest -data Ref' c = Ref (Storage' c) RefDigest - -type Ref = Ref' Complete -type PartialRef = Ref' Partial - -instance Eq (Ref' c) where - Ref _ d1 == Ref _ d2 = d1 == d2 - -instance Show (Ref' c) where - show ref@(Ref st _) = show st ++ ":" ++ BC.unpack (showRef ref) - -instance ByteArrayAccess (Ref' c) where - length (Ref _ dgst) = BA.length dgst - withByteArray (Ref _ dgst) = BA.withByteArray dgst - instance Hashable RefDigest where hashWithSalt salt ref = salt `xor` unsafePerformIO (BA.withByteArray ref peek) -instance Hashable (Ref' c) where - hashWithSalt salt ref = salt `xor` unsafePerformIO (BA.withByteArray ref peek) - -refStorage :: Ref' c -> Storage' c -refStorage (Ref st _) = st - -refDigest :: Ref' c -> RefDigest -refDigest (Ref _ dgst) = dgst - -showRef :: Ref' c -> ByteString -showRef = showRefDigest . refDigest - showRefDigestParts :: RefDigest -> (ByteString, ByteString) showRefDigestParts x = (BC.pack "blake2", showHex x) @@ -243,18 +214,18 @@ type Partial = Either RefDigest class (Traversable compl, Monad compl, Typeable compl) => StorageCompleteness compl where type LoadResult compl a :: Type returnLoadResult :: compl a -> LoadResult compl a - ioLoadBytes :: Ref' compl -> IO (compl BL.ByteString) + unsafeLoadBytes :: Storage' compl -> RefDigest -> IO (compl BL.ByteString) instance StorageCompleteness Complete where type LoadResult Complete a = a returnLoadResult = runIdentity - ioLoadBytes ref@(Ref st dgst) = maybe (error $ "Ref not found in complete storage: "++show ref) Identity + unsafeLoadBytes st dgst = maybe (error $ "Ref not found in complete storage: "++show dgst) Identity <$> ioLoadBytesFromStorage st dgst instance StorageCompleteness Partial where type LoadResult Partial a = Either RefDigest a returnLoadResult = id - ioLoadBytes (Ref st dgst) = maybe (Left dgst) Right <$> ioLoadBytesFromStorage st dgst + unsafeLoadBytes st dgst = maybe (Left dgst) Right <$> ioLoadBytesFromStorage st dgst ioLoadBytesFromStorage :: Storage' c -> RefDigest -> IO (Maybe BL.ByteString) ioLoadBytesFromStorage Storage {..} dgst = |