mirror of https://github.com/voidlizard/hbs2
wip, merge storage
This commit is contained in:
parent
31a476a73a
commit
98a97ba55f
|
@ -162,6 +162,28 @@ data NCQStorage =
|
|||
}
|
||||
|
||||
|
||||
instance MonadUnliftIO m => Storage NCQStorage HbSync LBS.ByteString m where
|
||||
putBlock ncq lbs = fmap coerce <$> ncqStoragePutBlock ncq lbs
|
||||
enqueueBlock ncq lbs = fmap coerce <$> ncqStoragePutBlock ncq lbs
|
||||
getBlock ncq h = ncqStorageGetBlock ncq (coerce h)
|
||||
hasBlock ncq = hasBlock ncq . coerce
|
||||
delBlock ncq = ncqStorageDel ncq . coerce
|
||||
|
||||
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
|
||||
|
||||
|
||||
data Location =
|
||||
InWriteQueue WQItem
|
||||
| InCurrent (Fd,Word64, Word64)
|
||||
|
|
|
@ -108,26 +108,6 @@ newtype TCQ =
|
|||
TCQ FilePath
|
||||
deriving newtype (Eq,Ord,Show,Typeable)
|
||||
|
||||
instance MonadUnliftIO m => Storage NCQStorage HbSync LBS.ByteString m where
|
||||
putBlock ncq lbs = fmap coerce <$> ncqStoragePutBlock ncq lbs
|
||||
enqueueBlock ncq lbs = fmap coerce <$> ncqStoragePutBlock ncq lbs
|
||||
getBlock ncq h = ncqStorageGetBlock ncq (coerce h)
|
||||
hasBlock ncq = hasBlock ncq . coerce
|
||||
delBlock ncq = ncqStorageDel ncq . coerce
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue