mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
ef88112822
commit
1eb0159b2d
|
@ -247,7 +247,7 @@ migrate syn = flip runContT pure $ callCC \exit -> do
|
||||||
refTo <- liftIO (readFile fn)
|
refTo <- liftIO (readFile fn)
|
||||||
<&> coerce @_ @HashRef . fromString @(Hash HbSync)
|
<&> coerce @_ @HashRef . fromString @(Hash HbSync)
|
||||||
|
|
||||||
here <- ncqLocate ncq refTo
|
here <- liftIO (ncqLocate ncq refTo)
|
||||||
|
|
||||||
if isJust here then do
|
if isJust here then do
|
||||||
liftIO $ ncqStorageSetRef ncq ref refTo
|
liftIO $ ncqStorageSetRef ncq ref refTo
|
||||||
|
|
|
@ -25,35 +25,35 @@ type StorageContext m = (MonadIO m, HasStorage m)
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageHasBlock where
|
instance (StorageContext m) => HandleMethod m RpcStorageHasBlock where
|
||||||
|
|
||||||
handleMethod href = do
|
handleMethod href = do
|
||||||
debug $ "rpc.storage.hasBlock" <+> pretty href
|
-- debug $ "rpc.storage.hasBlock" <+> pretty href
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ hasBlock sto (fromHashRef href)
|
liftIO $ hasBlock sto (fromHashRef href)
|
||||||
|
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageGetBlock where
|
instance (StorageContext m) => HandleMethod m RpcStorageGetBlock where
|
||||||
|
|
||||||
handleMethod href = do
|
handleMethod href = do
|
||||||
debug $ "rpc.storage.getBlock" <+> pretty href
|
-- debug $ "rpc.storage.getBlock" <+> pretty href
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ getBlock sto (fromHashRef href)
|
liftIO $ getBlock sto (fromHashRef href)
|
||||||
|
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageEnqueueBlock where
|
instance (StorageContext m) => HandleMethod m RpcStorageEnqueueBlock where
|
||||||
|
|
||||||
handleMethod lbs = do
|
handleMethod lbs = do
|
||||||
debug $ "rpc.storage.enqueueBlock"
|
-- debug $ "rpc.storage.enqueueBlock"
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ enqueueBlock sto lbs <&> fmap HashRef
|
liftIO $ enqueueBlock sto lbs <&> fmap HashRef
|
||||||
|
|
||||||
instance (StorageContext m) => HandleMethod m RpcStoragePutBlock where
|
instance (StorageContext m) => HandleMethod m RpcStoragePutBlock where
|
||||||
|
|
||||||
handleMethod lbs = do
|
handleMethod lbs = do
|
||||||
debug $ "rpc.storage.putBlock"
|
-- debug $ "rpc.storage.putBlock"
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ putBlock sto lbs <&> fmap HashRef
|
liftIO $ putBlock sto lbs <&> fmap HashRef
|
||||||
|
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageDelBlock where
|
instance (StorageContext m) => HandleMethod m RpcStorageDelBlock where
|
||||||
|
|
||||||
handleMethod href = do
|
handleMethod href = do
|
||||||
debug $ "rpc.storage.delBlock" <+> pretty href
|
-- debug $ "rpc.storage.delBlock" <+> pretty href
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ delBlock sto (fromHashRef href)
|
liftIO $ delBlock sto (fromHashRef href)
|
||||||
|
|
||||||
|
@ -66,21 +66,21 @@ instance (StorageContext m) => HandleMethod m RpcStorageGetChunk where
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageGetRef where
|
instance (StorageContext m) => HandleMethod m RpcStorageGetRef where
|
||||||
|
|
||||||
handleMethod ref = do
|
handleMethod ref = do
|
||||||
debug $ "rpc.storage.getRef" <+> pretty ref
|
trace $ "rpc.storage.getRef" <+> pretty ref
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ getRef sto ref <&> fmap HashRef
|
liftIO $ getRef sto ref <&> fmap HashRef
|
||||||
|
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageUpdateRef where
|
instance (StorageContext m) => HandleMethod m RpcStorageUpdateRef where
|
||||||
|
|
||||||
handleMethod (ref, val) = do
|
handleMethod (ref, val) = do
|
||||||
debug $ "rpc.storage.updateRef" <+> pretty ref <+> pretty (refMetaData ref)
|
trace $ "rpc.storage.updateRef" <+> pretty ref <+> pretty (refMetaData ref)
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ updateRef sto ref (fromHashRef val)
|
liftIO $ updateRef sto ref (fromHashRef val)
|
||||||
|
|
||||||
instance (StorageContext m) => HandleMethod m RpcStorageDelRef where
|
instance (StorageContext m) => HandleMethod m RpcStorageDelRef where
|
||||||
|
|
||||||
handleMethod ref = do
|
handleMethod ref = do
|
||||||
debug $ "rpc.storage.delRef" <+> pretty ref
|
trace $ "rpc.storage.delRef" <+> pretty ref
|
||||||
sto <- getStorage
|
sto <- getStorage
|
||||||
liftIO $ delRef sto ref
|
liftIO $ delRef sto ref
|
||||||
|
|
||||||
|
|
|
@ -1012,7 +1012,7 @@ ncqStorageGet_ ncq@NCQStorage{..} = \case
|
||||||
r <- atomically do
|
r <- atomically do
|
||||||
a <- newEmptyTMVar
|
a <- newEmptyTMVar
|
||||||
inRQ <- readTVar ncqCurrentReadReq <&> Seq.length
|
inRQ <- readTVar ncqCurrentReadReq <&> Seq.length
|
||||||
when (inRQ > 4 * ncqCapabilities) STM.retry
|
when (inRQ > 1024 * ncqCapabilities) STM.retry
|
||||||
modifyTVar ncqCurrentUsage (IntMap.insertWith (+) (fromIntegral fd) 1)
|
modifyTVar ncqCurrentUsage (IntMap.insertWith (+) (fromIntegral fd) 1)
|
||||||
modifyTVar ncqCurrentReadReq (|> (fd, o, l, a))
|
modifyTVar ncqCurrentReadReq (|> (fd, o, l, a))
|
||||||
pure a
|
pure a
|
||||||
|
|
Loading…
Reference in New Issue