mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
a2955197a3
commit
49c67a49dc
|
@ -296,7 +296,7 @@ runMessagingTCP env@MessagingTCP{..} = liftIO do
|
||||||
let (L4Address _ (IPAddrPort (i,p))) = own
|
let (L4Address _ (IPAddrPort (i,p))) = own
|
||||||
let myCookie = view tcpCookie env
|
let myCookie = view tcpCookie env
|
||||||
|
|
||||||
pause @'Seconds 30
|
pause @'Seconds 10
|
||||||
|
|
||||||
forever $ void $ runMaybeT do
|
forever $ void $ runMaybeT do
|
||||||
-- client sockets
|
-- client sockets
|
||||||
|
|
|
@ -234,7 +234,7 @@ runMessagingUnix env = do
|
||||||
void $ ContT $ bracket ( debug $ "Client thread started" <+> pretty that )
|
void $ ContT $ bracket ( debug $ "Client thread started" <+> pretty that )
|
||||||
( \_ -> debug $ "Client thread finished" <+> pretty that )
|
( \_ -> debug $ "Client thread finished" <+> pretty that )
|
||||||
|
|
||||||
void $ ContT $ bracket writer (\x -> pause @'Seconds 0.1 >> cancel x)
|
void $ ContT $ bracket writer (\x -> pause @'Seconds 0.25 >> cancel x)
|
||||||
|
|
||||||
fix \next -> do
|
fix \next -> do
|
||||||
|
|
||||||
|
|
|
@ -313,13 +313,10 @@ runCLI = do
|
||||||
pPoke = do
|
pPoke = do
|
||||||
rpc <- pRpcCommon
|
rpc <- pRpcCommon
|
||||||
pure $ withMyRPC @PeerAPI rpc $ \caller -> do
|
pure $ withMyRPC @PeerAPI rpc $ \caller -> do
|
||||||
e <- race ( pause @'Seconds 0.25) do
|
r <- callRpcWaitRetry @RpcPoke (TimeoutSec 0.5) 2 caller ()
|
||||||
r <- callService @RpcPoke caller ()
|
case r of
|
||||||
case r of
|
Nothing -> exitFailure
|
||||||
Left e -> die (show e)
|
Just s -> putStrLn s >> exitSuccess
|
||||||
Right txt -> putStrLn txt >> exitSuccess
|
|
||||||
|
|
||||||
liftIO $ either (const $ exitFailure) (const $ exitSuccess) e
|
|
||||||
|
|
||||||
pAnnounce = do
|
pAnnounce = do
|
||||||
rpc <- pRpcCommon
|
rpc <- pRpcCommon
|
||||||
|
|
|
@ -55,6 +55,7 @@ instance Monad m => HasOwnPeer UNIX (ReaderT RPC2Context m) where
|
||||||
|
|
||||||
instance (MonadUnliftIO m, HasProtocol UNIX (ServiceProto (api :: [Type]) UNIX))
|
instance (MonadUnliftIO m, HasProtocol UNIX (ServiceProto (api :: [Type]) UNIX))
|
||||||
=> HasDeferred (ServiceProto api UNIX) UNIX m where
|
=> HasDeferred (ServiceProto api UNIX) UNIX m where
|
||||||
deferred m = void $ asyncLinked m
|
deferred m = void $ async m
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -220,6 +220,15 @@ simpleStorageWorker ss@SimpleStorage{..} = do
|
||||||
atomically do
|
atomically do
|
||||||
modifyTVar lru (HashMap.filter notExpired)
|
modifyTVar lru (HashMap.filter notExpired)
|
||||||
|
|
||||||
|
ContT $ withAsync $ do
|
||||||
|
forever $ do
|
||||||
|
pause ( 10 :: Timeout 'Seconds ) -- FIXME: setting
|
||||||
|
purgeExpired _storageSizeCache
|
||||||
|
-- now <- getTimeCoarse
|
||||||
|
-- let notExpired t0 = not (expired timeout (now - t0))
|
||||||
|
-- atomically do
|
||||||
|
-- modifyTVar lru (HashMap.filter notExpired)
|
||||||
|
|
||||||
liftIO do
|
liftIO do
|
||||||
fix \next -> do
|
fix \next -> do
|
||||||
s <- atomically $ do TBMQ.readTBMQueue ( ss ^. storageOpQ )
|
s <- atomically $ do TBMQ.readTBMQueue ( ss ^. storageOpQ )
|
||||||
|
@ -364,7 +373,7 @@ simpleBlockExists ss hash = runMaybeT $ do
|
||||||
_ -> do
|
_ -> do
|
||||||
exists <- liftIO $ doesFileExist fn
|
exists <- liftIO $ doesFileExist fn
|
||||||
unless exists mzero
|
unless exists mzero
|
||||||
s <- liftIO $ getFileSize fn
|
s <- liftIO $! getFileSize fn
|
||||||
liftIO $ Cache.insert cache hash (Just s)
|
liftIO $ Cache.insert cache hash (Just s)
|
||||||
pure s
|
pure s
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue