mirror of https://github.com/voidlizard/hbs2
wip, Storage
This commit is contained in:
parent
f26cae04a3
commit
77589bfbbd
|
@ -114,10 +114,20 @@ instance MonadUnliftIO m => Storage NCQStorage HbSync LBS.ByteString m where
|
||||||
getBlock ncq h = ncqStorageGet ncq (coerce h)
|
getBlock ncq h = ncqStorageGet ncq (coerce h)
|
||||||
hasBlock ncq = hasBlock ncq . coerce
|
hasBlock ncq = hasBlock ncq . coerce
|
||||||
delBlock ncq = ncqStorageDel ncq . coerce
|
delBlock ncq = ncqStorageDel ncq . coerce
|
||||||
getChunk _ _ _ = error "getChunk not defined"
|
|
||||||
updateRef = error "updateRef not defined"
|
updateRef ncq k v = do
|
||||||
getRef = error "getRef not no defined"
|
ncqStorageSetRef ncq (HashRef $ hashObject k) (HashRef v)
|
||||||
delRef = error "delRef not defined"
|
|
||||||
|
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 :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
|
Loading…
Reference in New Issue