From 77589bfbbd7a171c22772c2dcce12d0449e8987c Mon Sep 17 00:00:00 2001 From: Dmitry Zuykov Date: Wed, 14 May 2025 13:40:00 +0300 Subject: [PATCH] wip, Storage --- hbs2-tests/test/TCQ.hs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hbs2-tests/test/TCQ.hs b/hbs2-tests/test/TCQ.hs index 5846dabb..efd23c3f 100644 --- a/hbs2-tests/test/TCQ.hs +++ b/hbs2-tests/test/TCQ.hs @@ -114,10 +114,20 @@ instance MonadUnliftIO m => Storage NCQStorage HbSync LBS.ByteString m where getBlock ncq h = ncqStorageGet ncq (coerce h) hasBlock ncq = hasBlock ncq . coerce delBlock ncq = ncqStorageDel ncq . coerce - getChunk _ _ _ = error "getChunk not defined" - updateRef = error "updateRef not defined" - getRef = error "getRef not no defined" - delRef = error "delRef not defined" + + updateRef ncq k v = do + ncqStorageSetRef ncq (HashRef $ hashObject k) (HashRef v) + + getRef ncq k = + ncqStorageGetRef ncq (HashRef $ hashObject k) <&> fmap coerce + + delRef ncq k = + ncqStorageDelRef ncq (HashRef $ hashObject k) + + getChunk ncq h off size = runMaybeT do + block <- lift (ncqStorageGetBlock ncq (coerce h)) >>= toMPlus + let chunk = LBS.take (fromIntegral size) $ LBS.drop (fromIntegral off) block + pure chunk main :: IO () main = do